Intel(R) Extension for Scikit-learn*

Intel(R) Extension for Scikit-learn is a seamless way to speed up your Scikit-learn application. The acceleration is achieved through the use of the Intel(R) oneAPI Data Analytics Library (oneDAL). Patching scikit-learn makes it a well-suited machine learning framework for dealing with real-life problems.

Designed for Data Scientists and Framework Designers

Intel(R) Extension for Scikit-learn* was created to give data scientists the easiest way to get a better performance while using the familiar scikit-learn package.

Intel(R) Extension for Scikit-learn* depends on Intel(R) daal4py. You can learn more in daal4py documentation.

Usage

Intel(R) Extension for Scikit-learn* dynamically patches scikit-learn estimators to use Intel(R) oneAPI Data Analytics Library as the underlying solver, while getting the same solution faster.

  • It is possible to enable those patches without editing the code of a scikit-learn application by using the following commandline flag:

    python -m sklearnex my_application.py
    
  • Or from your script:

    from sklearnex import patch_sklearn
    patch_sklearn()
    

For example:

from sklearnex import patch_sklearn
patch_sklearn()

from sklearn.cluster import KMeans
import numpy as np
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_}")
pred = kmeans.predict([[0, 0], [12, 3]])
print(f"pred = {pred}")
print(f"kmeans.cluster_centers_ = {kmeans.cluster_centers_}")

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 Scikit-learn with:

sklearnex.unpatch_sklearn()

Intel (R) Extension for Scikit-learn* does not patch all scikit-learn algorithms and parameters. You can find the full patching map here.

Note

Intel(R) Extension for Scikit-learn* supports optimizations for the last four versions of scikit-learn. The latest release of scikit-learn-intelex-2021.2.X supports scikit-learn 0.21.X, 0.22.X, 0.23.X and 0.24.X.

Support

Report issues, ask questions, and provide suggestions using:

You may reach out to project maintainers privately at onedal.maintainers@intel.com