Intel® Extension for Scikit-learn*

With Intel® Extension for Scikit-learn* you can accelerate your Scikit-learn applications and still have full conformance with all Scikit-Learn APIs and algorithms. Intel® Extension for Scikit-learn* is a free software AI accelerator that brings over 10-100X acceleration across a variety of applications.

Intel® Extension for Scikit-learn* offers you a way to accelerate existing scikit-learn code. The acceleration is achieved through patching: replacing the stock scikit-learn algorithms with their optimized versions provided by the extension.

Designed for Data Scientists and Framework Designers

Intel® Extension for Scikit-learn* was created to provide data scientists with a way to get a better performance while using the familiar scikit-learn package and getting the same results.


You may enable patching in different ways:


These patching methods are interchangeable. They support different enabling scenarios while producing the same result.

  • Without editing the code of a scikit-learn application by using the following command line flag:

    python -m sklearnex
  • Directly from the script:

    from sklearnex import patch_sklearn


You have to import scikit-learn after these lines. Otherwise, the patching will not affect the original scikit-learn estimators.

  • Through importing the desired estimator from the sklearnex module in your script:

    from sklearnex.neighbors import NearestNeighbors
  • Through global patching to enable patching for your scikit-learn installation for all further runs:

    python -m sklearnex.glob patch_sklearn


import numpy as np
from sklearnex import patch_sklearn

# You need to re-import scikit-learn algorithms after the patch
from sklearn.cluster import KMeans

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_}")

In the example above, you can see that the use of the original Scikit-learn has not changed. This behavior is achieved through drop-in patching.

To undo the patch, run:

# Re-import scikit-learn algorithms after the unpatch:
from sklearn.cluster import KMeans

You may specify which algorithms to patch:

  • Patching only one algorithm:

    from sklearnex import patch_sklearn
    # The names match scikit-learn estimators
  • Patching several algorithms:

    from sklearnex import patch_sklearn
    # The names match scikit-learn estimators
    patch_sklearn(["SVC", "DBSCAN"])