Scikit-learn is a comprehensive machine learning library for Python that provides a unified API for supervised and unsupervised learning algorithms, data preprocessing, model evaluation, and hyperparameter tuning. Built on top of NumPy, SciPy, and matplotlib README.rst49-50 it follows a strictly defined architectural pattern to ensure that over 150 different estimators can interoperate seamlessly in complex pipelines.
Scope: This page provides a high-level architectural overview. For detailed technical specifications, refer to the following child pages:
BaseEstimator, mixins, and validation. For details, see Core Foundation & API Design.Sources: README.rst49-50 doc/templates/index.html28-31
The scikit-learn design philosophy prioritizes consistency, inspection, and non-proliferation of classes.
All estimators share a common interface pattern defined by BaseEstimator sklearn/base.py44-457 This class provides standard implementations for parameter management via get_params and set_params, which are essential for hyperparameter search tools like GridSearchCV sklearn/model_selection/_search.py1047-1395
The library uses mixins to inject functionality and signal estimator types sklearn/base.py571-1104:
ClassifierMixin: Adds score() using accuracy sklearn/base.py696-776RegressorMixin: Adds score() using $R^2$ sklearn/base.py778-846TransformerMixin: Adds fit_transform() logic sklearn/base.py938-1035Input data is validated early using centralized utilities to ensure compatibility with underlying C/Cython extensions sklearn/utils/validation.py733-1193
Sources: sklearn/base.py44-1104 doc/developers/develop.rst85-158 sklearn/utils/validation.py733-1193
The following diagram illustrates the relationship between the core API layer and the specialized algorithm subsystems.
Diagram: High-Level Subsystem Interaction
Sources: sklearn/base.py sklearn/pipeline.py sklearn/model_selection/_validation.py doc/developers/develop.rst42-84
The estimator is the fundamental unit of scikit-learn. The architecture enforces a strict separation between model parameters (passed in __init__) and learned attributes (set in fit).
Diagram: Estimator Entity Mapping
Sources: sklearn/base.py44-1104 doc/developers/develop.rst85-174 sklearn/utils/validation.py610-730
Scikit-learn utilizes a modern build and CI infrastructure to support its high-performance components.
meson-python and Cython to compile performance-critical code pyproject.toml100-110sklearn/_min_dependencies.py sklearn/_min_dependencies.py1-62numpydoc, and sphinx-gallery to generate the website and example galleries doc/conf.py56-78Sources: pyproject.toml100-110 sklearn/_min_dependencies.py1-62 doc/conf.py56-78 build_tools/update_environments_and_lock_files.py60-84
| Package | Purpose | Primary Page |
|---|---|---|
sklearn.base | Foundation of the estimator API | BaseEstimator and Core Interfaces |
sklearn.preprocessing | Feature scaling and encoding | Data Preprocessing & Scaling |
sklearn.pipeline | Composition of multi-step workflows | Pipelines & Composition |
sklearn.linear_model | Linear algorithms (Lasso, Ridge, etc.) | Linear Models |
sklearn.ensemble | Tree-based ensembles and boosting | Tree-Based Models and Ensembles |
sklearn.model_selection | Cross-validation and tuning | Cross-Validation |
sklearn.metrics | Performance evaluation metrics | Metrics & Scoring |
sklearn.utils | Shared developer utilities | Data Validation System |
Sources: doc/developers/develop.rst22-84 sklearn/_min_dependencies.py22-62