Registry / ai-ml / scikit-learn

scikit-learn

JSON →
library1.9.0pypypi✓ verified 26d ago

Scikit-learn is a free and open-source machine learning library for Python, built on NumPy and SciPy. It provides a wide range of efficient tools for predictive data analysis, including algorithms for classification, regression, clustering, dimensionality reduction, and model selection. Known for its consistent API and comprehensive documentation, it is actively maintained with a regular release cadence. The latest stable version is 1.8.0.

pip install -U scikit-learn
INSTALL
IMPORT
SIG · SCIKIT-LEARN
S
scikit-learn
ai-mlpythonv1.9.0
Install
9.9s avg
Import
3270ms
Disk
280MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.7.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
build_error
glibc
py 3.103.95 runs
installs and imports cleanly · install 9.9s · import 3.270s · 270MB
280MB installed
● package 280MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

sklearn
import sklearn
from sklearn import ClassName (after pip install sklearn)
While 'import sklearn' is the correct module name, the PyPI package to install is 'scikit-learn'. Installing 'sklearn' from PyPI will install a deprecated placeholder package (version 0.0.x) that is not the actual scikit-learn library and will raise warnings or errors. Always use 'pip install scikit-learn'.
RandomForestClassifier
from sklearn.ensemble import RandomForestClassifier
Imports for specific estimators or utilities are typically from submodules like `sklearn.ensemble`, `sklearn.linear_model`, `sklearn.preprocessing`, etc.
train_test_split
from sklearn.model_selection import train_test_split
Model selection tools are found in `sklearn.model_selection`.

This quickstart demonstrates a typical Scikit-learn workflow: generating data, splitting it into training and testing sets, training a `RandomForestClassifier` with keyword arguments, making predictions, and evaluating the model. It also shows a simple `Pipeline` combining a preprocessor and a classifier.

import numpy as np from sklearn.ensemble import RandomForestClassifier from sklearn.datasets import make_classification from sklearn.model_selection import train_test_split from sklearn.metrics import accuracy_score # 1. Generate synthetic data X, y = make_classification(n_samples=1000, n_features=4, random_state=42) # 2. Split data into training and testing sets X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) # 3. Instantiate a classifier (estimator) # Use keyword arguments for parameters, as positional arguments are deprecated (sklearn >= 1.0) clf = RandomForestClassifier(n_estimators=100, random_state=42) # 4. Fit the classifier to the training data clf.fit(X_train, y_train) # 5. Make predictions on the test data y_pred = clf.predict(X_test) # 6. Evaluate the model accuracy = accuracy_score(y_test, y_pred) print(f"Model Accuracy: {accuracy:.2f}") # Example of using a preprocessor (e.g., StandardScaler in a pipeline context) from sklearn.preprocessing import StandardScaler from sklearn.pipeline import make_pipeline from sklearn.linear_model import LogisticRegression pipe = make_pipeline(StandardScaler(), LogisticRegression(random_state=42)) pipe.fit(X_train, y_train) pipeline_accuracy = accuracy_score(pipe.predict(X_test), y_test) print(f"Pipeline Accuracy: {pipeline_accuracy:.2f}")
Debug
Known issues
breakingDo NOT install 'sklearn' from PyPI. The 'sklearn' PyPI package is a deprecated placeholder and will lead to errors or install an outdated/dummy package. Always install the library using 'pip install scikit-learn'.
fix
Use `pip install scikit-learn` for installation. If you have `sklearn` installed, uninstall it with `pip uninstall sklearn` and then `pip install scikit-learn`. If a dependency requires `sklearn`, report it to their issue tracker or set `SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL=True` as a last resort.
affects: All versions (installation method)
breakingPositional arguments for estimator instantiation and method calls are deprecated since version 0.23 and now raise a TypeError in Scikit-learn 1.0 and later for most parameters.
fix
Always use keyword arguments when instantiating estimators or calling methods with multiple parameters. For example, use `RandomForestClassifier(n_estimators=100)` instead of `RandomForestClassifier(100)`.
affects: >= 1.0.0 (warnings since 0.23)
deprecatedThe `get_feature_names` method on transformers is deprecated.
fix
Use `get_feature_names_out` instead to retrieve the names of output features from a transformer.
affects: >= 1.0.0
gotchaUsage of `numpy.matrix` as input to Scikit-learn estimators is deprecated.
fix
Convert `numpy.matrix` inputs to `numpy.ndarray` (e.g., using `.A` attribute or `np.asarray()`) before passing them to Scikit-learn estimators.
affects: >= 1.0.0 (will raise TypeError in 1.2)
gotchaScikit-learn 1.0+ stores feature names in `feature_names_in_` when fitted on pandas DataFrames. Inconsistent feature names during subsequent `transform` (or other non-fit methods) will raise a `FutureWarning` which will become a `ValueError` in version 1.2.
fix
Ensure that the feature names (column names of pandas DataFrames) are consistent between `fit` and subsequent operations (`transform`, `predict`). If feature names are not important, consider converting DataFrames to NumPy arrays (e.g., `df.values`) before passing them to estimators.
affects: >= 1.0.0 (warnings), >= 1.2.0 (errors)
Upgrade
Version history
1.9.0latest on PyPI · released Jun 2, 2026
Audit
Dependencies
numpyrequiredRequired for numerical operations and array handling.
scipyrequiredRequired for scientific computing and various algorithms.
joblibrequiredRequired for efficient parallel computing.
threadpoolctlrequiredRequired for controlling thread pools.
matplotliboptionalOptional, required for plotting capabilities (e.g., plot_ and Display classes).
pandasoptionalOptional, often used for data handling, especially with feature names support.
scikit-imageoptionalOptional, required for some examples.
seabornoptionalOptional, required for some examples and enhanced plotting.
plotlyoptionalOptional, required for some examples and interactive plotting.
Agent activity
33 hits · last 30 days
node
28
OpenAI (training)
1
Resources
scikit-learn — pip install scikit-learn · libregistry