
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Install Python Scikit-Learn
Scikit-learn, also known as Sklearn, is the most useful and robust open-source Python library that implements machine learning and statistical modeling algorithms including classification, regression, clustering, and dimensionality reduction using a unified interface. Scikit-learn library is written in Python and is built upon other Python packages such as NumPy (Numerical Python), and SciPy (Scientific Python).
Installing Scikit-learn on Windows using pip
To install Scikit-learn on Windows, follow the steps given below ?
Step1-Make Sure Python and pip is preinstalled
Open the command prompt on your system and type the following commands to check whether Python and pip is installed or not.
To check Python
Python --version
If you have python on your system, it will display the version of python installed. If not, you can manually install python from https://www.python.org..
To check pip
pip --version
If pip is successfully installed on your system, it will display its version.
Step2-Install Scikit-learn Library
Scikit-learn can be installed using pip. You can run the following command in command prompt to install scikit-learn ?
pip install scikit-learn
The above command will start downloading and installing packages related to the Scikit-learn Python library. Once done, it will display the message of successful installation.
Installing Scikit-learn on Windows using conda
Anaconda, a python distribution platform, offers scikit-learn as part of its free distribution.
You can update the scikit-learn package with the help of below given steps ?
Step1-Make Sure Python and conda is preinstalled
Open the Anaconda command prompt on your system and type the following commands to check whether Python and conda is installed or not.
To check Python
Python --version
If you have python on your system, it will display the version of python installed.
To check conda
conda --version
If conda is successfully installed on your system, it will display its version. It is always recommended to update conda to its latest version by using the following command ?
conda update conda
Step2-Update Scikit-learn Library
As discussed, scikit-learn is preinstalled in Anaconda Python environment. Use the following command to check the installed version of the scikit-learn library ?
conda list scikit-learn
It will display the version of scikit-learn installed on your system in Anaconda distribution.
Now to update it to the latest version, type the following command at the terminal ?
conda update scikit-learn
Alternatively, you can update scikit-learn library to a specific version by typing ?
conda install -c anaconda scikit-learn=1.0.2
The above command will start downloading and installing packages related to the Scikit-learn Python library. Once done, it will display the message of successful installation.
Installing Scikit-learn on macOS
To install Scikit-learn on macOS, follow the steps given below ?
Step1-Install Python 3 using homebrew package manager
Before installing scikit-learn on your macOS, you need Python 3 preinstalled. Use homebrew package manager to install Python3.
brew install python
Alternatively, you can manually install python from https://www.python.org.
Step2-Install Scikit-learn Library
Scikit-learn can be installed using pip. You can run the following command to install the latest release of scikit-learn ?
pip install -U scikit-learn
The above command will start downloading and installing packages related to the Scikit-learn Python library. Once done, it will display the message of successful installation.
Use the below command to check your installation ?
python -m pip show scikit-learn
Installing Scikit-learn on macOS in virtual environment
To install Scikit-learn on macOS in virtual environment, follow the steps given below ?
Step1-Install Python 3 using homebrew package manager
Before installing scikit-learn on your macOS, you need Python 3 preinstalled. Use homebrew package manager to install Python3.
brew install python
Alternatively, you can manually install python from https://www.python.org.
Step2-Creating pip virtual environment
Once python is installed on your system, you need to create a virtual environment by typing ?
python -m venv sklearn-venv
The above command will create a virtual environment named Sklearn-venv. To activate this virtual environment, type ?
source Sklearn-venv/bin/activate
Step3-Install Scikit-learn Library
You can now use pip to install the latest release of scikit-learn in above created virtual environment.
pip install -U scikit-learn
To check your installation, type ?
python -m pip show scikit-learn
To avoid conflicts with other installed packages, it is always recommended to use a virtual environment.
Installing Scikit-learn on Linux
To install Scikit-learn on Linux distribution, follow the steps given below ?
Step1-Make Sure Python3 and pip3 is preinstalled
Open the command prompt on your system and type the following commands to check whether Python3 and pip3 is installed or not.
To check Python
Python3 --version
If you have python on your system, it will display the version of python installed.
If not, run below command to install Python3 ?
sudo apt-get install python3.6
The above command will install Python 3.6 on Ubuntu 16.10 or newer.
To check pip
To see if pip3 is installed, open a command prompt, run the below command ?
command -v pip3
If pip is successfully installed on your system, it will display its version.
Step2-Install Scikit-learn Library
Type and run the command given below to install the latest release of scikit-learn on your Linux distribution ?
Pip3 install -U scikit-learn
You can use the below command to check scikit-learn installation ?
Python3 -m pip show scikit-learn
Installing Scikit-learn on Linux in virtual environment
To install Scikit-learn on Linux in virtual environment, follow the steps given below:
Step1-Make Sure Python3 and pip3 is preinstalled
Open the command prompt on your system and type the following commands to check whether Python3 and pip3 is installed or not.
To check Python
Python3 --version
If you have python on your system, it will display the version of python installed.
If not, run below command to install Python3 ?
sudo apt-get install python3.6
The above command will install Python 3.6 on Ubuntu 16.10 or newer.
To check pip
To see if pip3 is installed, open a command prompt, run the below command ?
command -v pip3
If pip is successfully installed on your system, it will display its version.
Step2-Creating pip virtual environment
Create a virtual environment by typing ?
python3 -m venv sklearn-venv
The above command will create a virtual environment named Sklearn-venv. To activate this virtual environment, type ?
source sklearn-venv/bin/activate
Step3-Install Scikit-learn Library
You can now use pip to install the latest release of scikit-learn in above created virtual environment.
Pip3 install -U scikit-learn
To check your installation, run the below command ?
python3 -m pip show scikit-learn
To avoid conflicts with other installed packages, it is always recommended to use a virtual environment.