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
muslpy 3.10–3.95 runs
build_error
glibcpy 3.10–3.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'.fixUse `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.fixAlways 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.fixUse `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.fixConvert `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.fixEnsure 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.