Favicon of scikit-learn

scikit-learn

A Python module for machine learning, built on SciPy, providing algorithms for classification, regression, clustering, and model evaluation.

scikit-learn is a Python module for machine learning built on top of SciPy. It's the standard library for classical (non-deep-learning) machine learning in Python: classification, regression, clustering, dimensionality reduction, and model selection, all exposed through a consistent, well-documented API. It's aimed at data scientists, researchers, and developers who need reliable, well-tested implementations of standard machine learning algorithms without writing them from scratch or wiring together lower-level numerical libraries themselves.

Key features

  • Consistent estimator API: nearly every algorithm follows the same fit/predict/transform pattern, so switching between models or building pipelines requires minimal code changes.
  • Broad algorithm coverage: classification, regression, clustering, and dimensionality reduction algorithms are included as part of the core library rather than scattered across separate packages.
  • Built on SciPy and NumPy: relies on the established Python scientific computing stack rather than introducing its own numerical foundations, which keeps it interoperable with the rest of that ecosystem.
  • Plotting and display utilities: functions prefixed plot_ and classes ending in Display provide built-in visualization for model results, when Matplotlib is installed.
  • Long-running, actively maintained project: started in 2007 as a Google Summer of Code project and maintained continuously since by a volunteer team, with a documented changelog of notable changes across versions.
  • Extensive documentation and examples: HTML documentation for both the current stable release and the development version, with a large example gallery covering common use cases.
  • BSD-licensed: permissively licensed, so it can be used in commercial and closed-source projects without licensing concerns.
  • Citable for research: the project provides a DOI through Zenodo, so results built on scikit-learn can be formally cited in scientific publications.

Ideal use cases

scikit-learn is the default choice for classical machine learning tasks on structured/tabular data: building and evaluating classifiers or regressors, clustering unlabeled data, reducing dimensionality before visualization or modeling, and building preprocessing and modeling pipelines that need to be reproducible and easy to hand off to other Python developers. Its consistent API also makes it a common teaching tool, since the same fit/predict pattern applies across nearly every algorithm in the library.

It is not a deep learning framework. scikit-learn doesn't provide GPU-accelerated neural network training, automatic differentiation, or the building blocks for custom deep architectures; for that, frameworks like PyTorch or TensorFlow are the appropriate tools. It's also not built for datasets that don't fit in memory or need distributed training across a cluster by default, since it's designed around in-memory NumPy/SciPy arrays rather than a distributed compute model.

For help beyond the documentation, the project runs GitHub Discussions and a Discord server for developer and support questions, a long-running mailing list for broader discussion, and a public community calendar, in addition to the large volume of scikit-learn questions already answered on Stack Overflow. The project also maintains a changelog documenting notable changes across releases, and official logos and branding assets are published for anyone writing or presenting about it.

Installation

If you already have NumPy and SciPy installed, the simplest install is via pip:

pip install -U scikit-learn

Or via conda:

conda install -c conda-forge scikit-learn

Required dependencies are Python 3.11+, NumPy 1.24.1+, SciPy 1.10.0+, Narwhals 2.0.1+, joblib 1.4.0+, and threadpoolctl 3.5.0+. Plotting functions and classes (those prefixed plot_ or ending in Display) additionally require Matplotlib 3.6.1+.

To work from the latest source instead of a released version:

git clone https://github.com/scikit-learn/scikit-learn.git

After installation, the test suite can be run from outside the source directory with pytest 7.1.2 or newer:

pytest sklearn

The SKLEARN_SEED environment variable can be set to control random number generation during testing, useful for reproducing test failures.

Frequently asked questions

Share:

Stars
66.6K
Forks
27.2K
Last commit
5 hours ago
Repository age
16 years
License
BSD-3-Clause
Self-hosted
No
Activity score
90/100
View Repository
Built with:

Similar to scikit-learn

Favicon

 

  
  
Favicon

 

  
  
Favicon