×

How to Install Scikit-Learn

Sklearn or Scikit-learn is a python library used for machine learning. It contains many features like classification, regression, clustering, and Dimensionality reduction algorithms. Sklearn is used to build machine learning models, so it cannot be used for manipulating Data and summarizing data.

It also provides efficient tools for machine learning and statistical modeling, including python regression, classification, and clustering. This library is built upon NumPy, SciPy, and Matplotlib in python. With this library it is easy to write machine learning algorithms.

This article lets us learn how to install the Scikit-learn library in python.

Before installing Sklearn, we first need to have python of version 2.6 or above, and also, you have to install NumPy and scipy from their official installers, then you have to install Sklearn.

For installing in Windows, you use the below command:

Pip install  scikit-learn

Or

pip install -U scikit-learn

You can also install scikit-learn using conda by taking the following command:

conda install scikit-learn

For installing on Mac OSX, you use the following command:

Pip install -U numpy scipy scikit-learn

For installing in Linux, you must first install the dependencies needed for python development.

So, if you are using Python 2, then you can use the following commands to install the requirements

sudo apt-get install build-essential python-dev python-setuptools \
 python-numpy python-scipy \
 libatlas-dev libatlas3gf-base

If you have Python 3, then you use the following commands to install the requirements

sudo apt-get install build-essential python3-dev python3-setuptools \
python3-NumPy python3-scipy \
libatlas-dev libatlas3gf-base


With these commands, the following dependencies will be automatically installed with scikit-learn

  • NumPy 1.13.3+
  • SciPy 0.19.1+
  • Joblib 0.11+
  • Threadpoolctl 2.0.0+

You can verify your installation by using the following command:

python -m pip show scikit-learn

Then you can check the dependencies and the scikit-learn installed in your system.

As you installed scikit-learn in the programs, we must import that library into the code by using the following command.

import sklearn

it is not always necessary to import all of the scikit-learn functions; instead, you can import the functions you need for that particular project using the following command.

from sklearn, import linear_model

For example, let us have a look at an example code given below:

From sklearn import datasets


iris= datasets.load_jarvis()


print(jarvis.data.shape)

Output

How to Install Scikit-Learn

In the above code, we loaded a data set with the name Jarvis, and it is a dataset of a flower, and it contains 150 observations with different lengths of flowers and printed shapes of that Data set; hence after execution, we got the output showing the size of (150, 4).

In that way, we can only import the required functions for a project.

Features of Scikit-learn

  • Supervised learning
  • Unsupervised learning
  • Reinforcement learning

Supervised learning: The data set must be in a labelled format so that the supervised learning algorithm gives a gathered function after analysis of the training data, which is used to map new data sets. And there are two types of problems in supervised learning: classification and regression.

Supervised learning algorithms:

  • k-nearest neighbours
  • linear regression
  • logistic regression
  • support vector machine (SVM)
  • decision trees

Unsupervised learning

This is also a machine learning algorithm which is also known as unlabelled. This is used to figure out the conclusion from datasets consisting of input data without labelled responses. Unsupervised learning uses only one method, clustering, to find the hidden patterns of a data set.

Unsupervised learning algorithms:

  • k-means
  • fuzzy k-means
  • hierarchical clustering
  • mixture of Gaussians

Reinforcement learning:

This is one of the basic machine learning algorithms; this is all about making decisions sequentially. So, every output depends based on the previous inputs. For example, we can take an online chess game.

Conclusion

Thus, by reading this article, you can understand what sklearn is, its importance of it and how to install sklearn in windows, mac, and Linux, and its dependencies in various ways. And, how to import and use that sklearn in the python projects and its shortcuts. Then we covered the features of sklearn, which are supervised, unsupervised, and reinforcement learning, including their features also. We also looked at an example program where we know how to load a data set and find its features. Therefore, with all these, we completed the basics of sklearn and its installation.


Related Topics

Programs for Printing Pyramid Patterns in Python

<!-- wp:paragraph --><p>Python supports printing patterns using basic for loops. The number of rows is handled by the first outer loop, while the number of columns is handled by the...

9 minutes read.

Syntax of Map function in Python

In this tutorial, we will understand what the map function in Python is meant. Further, we will see the syntax to be used for the same in python language. We...

3 minutes read.

Python Graph

Python Graph: In Computer Science and Mathematics, a Graph is a pictorial representation of a group of objects or elements where some elements are connected using the links. A graph...

5 minutes read.

wxPython Panel class

wxPython Panel class The Widgets which is shown in the frame of GUI window such as text box, buttons, static text etc. are put inside the panel class of the wxpython...

2 minutes read.

Python coding platform

Python is a popular general-purpose programming language with many applications. High-level data structures, datatypes, dynamic binding, and many other features make it useful for both designing complex applications and "glue...

6 minutes read.

How to Install Matplotlib in Python?

How to Install Matplotlib in Python The speed at which the enormous amount of data is generating has become a huge aid in understanding what's going on currently in the market....

4 minutes read.

Ternary operators in python

Starting from Python version 2.5, ternary operators are also known as Conditional operators. Using these operators, we can evaluate any problem based on a condition. It is an alternative and...

4 minutes read.

Python List

The list is one of the most versatile, mutable data-structures in Python. It can store heterogeneous data or different types of data. The list contains comma-separated values (item) within the square brackets. Creating...

4 minutes read.

Hypothesis Testing in Python

Hypothesis Testing in python is widely used along with statistics. Many libraries in Python are very useful for statistics and machine learning. Libraries like numpy, scripy etc. help in hypothesis testing in...

12 minutes read.

Python Call Function

In this article, you will learn about calling a function in Python. But before learning this, we should know about functions in Python.So, let’s get some overview of functions in...

6 minutes read.

Count Number of Keys in Dictionary Python

Dictionary is a particular data type in python. Dictionary stores unique values by taking different keys and their assigned values. Through this article, we will learn about python dictionary count,...

3 minutes read.

Mrcnn Python

Python Programming Language Python programming language is one of the most used programming languages, as it is used widely in the field of software and data analysis, web development, etc. It...

6 minutes read.

Raise Exception in Python

Most of the programmers/developers create large programs to solve complex tasks in Python. The code can be of 1000 lines and even more based on the need of the problem....

5 minutes read.

Python Subprocess Call Example

Python Programming Language: Python programming language is one of the most used programming languages, as it is used widely in the field of software and data analysis, web development, etc. It...

4 minutes read.

Python pow() Function

Python pow() Function The pow() function in Python return the parameter ‘x’ to the power ‘y’ and if the parameter ‘z’ is present, it returns x to the power y, modulo z (computed more efficiently than pow(x, y) % z). Syntax pow(x, y[, z]) Parameter x: This parameter represents the base...

1 minute read.

Python random.seed() function

The random module in Python produces a random number or pseudo-random data, that is, deterministic. The seed function records the state of a random function to provide the same random...

6 minutes read.

Python Dictionary update() method

Python Dictionary update() method The dictionary.update() method in Python inserts the specified items to the dictionary. Syntax dictionary.update(iterable) Parameter iterable- This parameter represents a dictionary or an iterable object with key value pairs, that will...

1 minute read.

Python String rfind() method

The string. rfind() method in Python returns the highest index in the string if the substring sub is found else it returns -1 if the substring is not found. Syntax string.rfind(sub [,start [,end]]) Parameter sub: This parameter...

2 minutes read.

Difference between Module and Package in Python

The main difference between the module and the package in Python is that the module can be a simple file in Python that contains the different functions and collection of...

4 minutes read.

Python Word Tokenizer

Python Overview Python is an Object-Oriented high-level language. Python is designed to be highly beginner-friendly. Python has an English-like syntax, which is very easy to read. Python is an interpreted language...

4 minutes read.