Conda is a popular open-source package management system and environment management system used in data science and machine learning. It provides a convenient way to install scikit-learn and manage its dependencies.
This example will show how to install scikit-learn using conda on Windows, macOS, and Linux.
To install scikit-learn with conda, run the following command in your terminal or Anaconda Prompt:
conda install -c conda-forge scikit-learn
The -c conda-forge
option specifies the conda-forge channel, which provides a more up-to-date version of scikit-learn compared to the default conda channel.
To confirm that scikit-learn was successfully installed, you can import it in a Python script or interactive shell and print out the version number:
import sklearn
print(sklearn.__version__)
Running the example gives an output like:
1.5.0
The first code block shows the
conda install
command to install scikit-learn using conda. The-c conda-forge
option ensures that the latest version is installed from the conda-forge channel.The second code block imports the installed
sklearn
library and prints its version number usingsklearn.__version__
.This is a quick way to verify that scikit-learn was properly installed and is available for use in your conda environment.