In this article, we are going to see how to install Scikit-Learn on Linux. Scikit-Learn is a python open source library for predictive data analysis. It is built on NumPy, SciPy, and matplotlib. It is written in Python, Cython, C, and C++ language. It is available for Linux, Unix, Windows, and Mac.
Method 1: Installing Scikit-Learn from source
Step 1: Installing python3 and the essentials dependencies to build the Scikit-learn.
sudo apt-get install build-essential python3-dev python3-pip
Step 2: Got the scikit-learn repository and clone it using the following command.
git clone git://github.com/scikit-learn/scikit-learn.git --depth 1 cd scikit-learn
Step 3: Create a virtual environment for separate installation of Scikit-learn.
To install the python3-virtualenv tool, if you have not installed it yet.
sudo apt install python3.8-venv
Run the following command to create and activate the virtual environment.
python3 -m venv Lazyroar-env
This will create a virtual environment called Lazyroar-env
source Lazyroar-env/bin/activate
The above command will activate the virtual environment.
Step 4: Now, Install NumPy, SciPy, and Cython and build the package with pip in Editable mode:
pip install numpy scipy cython
Building the package:
pip install --verbose --no-build-isolation --editable .
Step 5: Verifying the installation.
python3 -c "import sklearn; sklearn.show_versions()"
Method 2: Installing Scikit-Learn using the pip command
Step 1: Install Scikit-learn using the following pip installation command:
pip3 install -U scikit-learn
Step 2: Verify the installation by running the following command:
python3 -m pip show scikit-learn