Quick Start
Get ready to elevate your scikit-learn code with Extension for Scikit-learn* and experience the benefits of accelerated performance in just a few simple steps.
Compatibility with Scikit-learn*
Extension for Scikit-learn* is compatible with the latest stable releases of scikit-learn - see Software Requirements for more details.
Integrate Extension for Scikit-learn*
Patching
Once you install the Extension for Scikit-learn*, you can replace estimator classes (algorithms) that exist in the sklearn
module from scikit-learn with their optimized versions from the extension.
This action is called patching. This is not a permanent change so you can always undo the patching if necessary.
To patch scikit-learn with the Extension for Scikit-learn*, the following methods can be used:
Method |
Action |
---|---|
Use a flag in the command line |
Run this command: python -m sklearnex my_application.py
|
Modify your script |
Add the following lines: from sklearnex import patch_sklearn
patch_sklearn()
|
Import an estimator from the |
Run this command: from sklearnex.neighbors import NearestNeighbors
|
These patching methods are interchangeable. They support different enabling scenarios while producing the same result.
Example
This example shows how to patch scikit-learn by modifing your script. To make sure that patching is registered by the scikit-learn estimators, always import module sklearn
after these lines.
import numpy as np
from sklearnex import patch_sklearn
patch_sklearn()
# You need to re-import scikit-learn algorithms after the patch
from sklearn.cluster import KMeans
# The use of the original Scikit-learn is not changed
X = np.array([[1, 2], [1, 4], [1, 0],
[10, 2], [10, 4], [10, 0]])
kmeans = KMeans(n_clusters=2, random_state=0).fit(X)
print(f"kmeans.labels_ = {kmeans.labels_}")
Global Patching
You can also use global patching to patch all your scikit-learn applications without any additional actions.
Before you begin, make sure that you have read and write permissions for Scikit-learn files.
With global patching, you can:
Task |
Action |
Note |
---|---|---|
Patch all supported algorithms |
Run this command: python -m sklearnex.glob patch_sklearn
|
If you run the global patching command several times with different parameters, then only the last configuration is applied. |
Patch selected algorithms |
Use python -m sklearnex.glob patch_sklearn -a svc random_forest_classifier
|
|
Enable global patching via code |
Use the from sklearnex import patch_sklearn
patch_sklearn(global_patch=True)
import sklearn
|
After that, Scikit-learn patches is enabled in the current application and in all others that use the same environment. |
Disable patching notifications |
Use python -m sklearnex.glob patch_sklearn -a svc random_forest_classifier -nv
|
|
Disable global patching |
Run this command: python -m sklearnex.glob unpatch_sklearn
|
|
Disable global patching via code |
Use the from sklearnex import unpatch_sklearn
unpatch_sklearn(global_patch=True)
|
Tip
If you clone an environment with enabled global patching, it will already be applied in the new environment.
Unpatching
To undo the patch (also called unpatching) is to return the sklearn
module to the original implementation and
replace patched estimators with the stock scikit-learn estimators.
To unpatch successfully, you must reimport the sklearn
module(s):
sklearnex.unpatch_sklearn()
# Re-import scikit-learn algorithms after the unpatch
from sklearn.cluster import KMeans
Installation
Tip
To prevent version conflicts, we recommend creating and activating a new environment for Extension for Scikit-learn*.
Install from PyPI
Recommended by default.
To install Extension for Scikit-learn*, run:
pip install scikit-learn-intelex
Supported Configurations
Operating systems |
Windows*, Linux* |
Python versions |
3.9, 3.10, 3.11, 3.12, 3.13 |
Devices |
CPU, GPU |
Modes |
Single, SPMD |
Tip
Running on GPU involves additional dependencies, see oneAPI and GPU support in Extension for Scikit-learn*. SPMD mode has additional requirements on top of GPU ones, see Distributed Mode (SPMD) for details.
Note
Wheels are only available for x86-64 architecture.
Install from Anaconda* Cloud
To prevent version conflicts, we recommend installing scikit-learn-intelex into a new conda environment.
Note: the main Anaconda channel also provides distributions of scikit-learn-intelex, but it does not provide the latest versions, nor does it provide GPU-enabled builds. It is highly recommended to install it from either Intel’s channel or conda-forge instead.
Recommended for the Intel® Distribution for Python users.
To install, run:
conda install -c https://software.repos.intel.com/python/conda/ scikit-learn-intelex
Operating systems |
Windows*, Linux* |
Python versions |
3.9, 3.10, 3.11, 3.12, 3.13 |
Devices |
CPU, GPU |
Modes |
Single, SPMD |
To install, run:
conda install -c conda-forge scikit-learn-intelex
Operating systems |
Windows*, Linux* |
Python versions |
3.9, 3.10, 3.11, 3.12, 3.13 |
Devices |
CPU, GPU |
Modes |
Single, SPMD |
Tip
Running on GPU involves additional dependencies, see oneAPI and GPU support in Extension for Scikit-learn*. SPMD mode has additional requirements on top of GPU ones, see Distributed Mode (SPMD) for details.
Note
Packages are only available for x86-64 architecture.
Build from Sources
See Installation instructions to build Extension for Scikit-learn* from the sources.
Install Intel*(R) AI Tools
Download the Intel AI Tools here. The extension is already included.
Release Notes
See the Release Notes for each version of Extension for Scikit-learn*.
System Requirements
Hardware Requirements
Any processor with x86-64
architecture with at least one of the following instruction sets:
SSE2
SSE4.2
AVX2
AVX512
Note
Note: pre-built packages are not provided for other CPU architectures. See Build from Sources for ARM.
Tip
Read more about hardware comparison in our blogs.
Software Requirements
Linux* OS: Ubuntu* 18.04 or newer
Windows* OS 10 or newer
Windows* Server 2019 or newer
A Linux* or Windows* version supported by DPC++ and oneMKL
Intel® GPGPU drivers
DPC++ runtime libraries
Important
If you use accelerators (e.g. GPUs), refer to oneAPI DPC++/C++ Compiler System Requirements.
Extension for Scikit-learn* is compatible with the latest stable releases of scikit-learn:
1.0.X
1.1.X
1.2.X
1.3.X
1.4.X
1.5.X
1.6.X
Memory Requirements
By default, algorithms in Extension for Scikit-learn* run in the multi-thread mode. This mode uses all available threads. Optimized scikit-learn estimators can consume more RAM than their corresponding unoptimized versions.
Algorithm |
Single-thread mode |
Multi-thread mode |
---|---|---|
SVM |
Both scikit-learn and Extension for Scikit-learn* consume approximately the same amount of RAM. |
In Extension for Scikit-learn*, an algorithm with |
In all Extension for Scikit-learn* algorithms with GPU support, computations run on device memory. The device memory must be large enough to store a copy of the entire dataset. You may also require additional device memory for internal arrays that are used in computation.
See also