Installation | Documentation | Examples | Support | FAQ
With Intel(R) Extension for Scikit-learn you can accelerate your Scikit-learn applications and still have full conformance with all Scikit-Learn APIs and algorithms. This is a free software AI accelerator that brings over 10-100X acceleration across a variety of applications. And you do not even need to change the existing code!
Intel(R) 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.
One of the ways to patch scikit-learn is by modifying the code. First, you import an additional Python package (sklearnex
) and enable optimizations via sklearnex.patch_sklearn()
. Then import scikit-learn estimators:
-
Enable Intel CPU optimizations
import numpy as np from sklearnex import patch_sklearn patch_sklearn() from sklearn.cluster import DBSCAN X = np.array([[1., 2.], [2., 2.], [2., 3.], [8., 7.], [8., 8.], [25., 80.]], dtype=np.float32) clustering = DBSCAN(eps=3, min_samples=2).fit(X)
-
Enable Intel GPU optimizations
import numpy as np import dpctl from sklearnex import patch_sklearn, config_context patch_sklearn() from sklearn.cluster import DBSCAN X = np.array([[1., 2.], [2., 2.], [2., 3.], [8., 7.], [8., 8.], [25., 80.]], dtype=np.float32) with config_context(target_offload="gpu:0"): clustering = DBSCAN(eps=3, min_samples=2).fit(X)
👀 Read about other ways to patch scikit-learn and other methods for offloading to GPU devices. Check out available notebooks for more examples.
This software acceleration is achieved through the use of vector instructions, IA hardware-specific memory optimizations, threading, and optimizations for all upcoming Intel platforms at launch time.
❗ The patching only affects selected algorithms and their parameters.
You may still use algorithms and parameters not supported by Intel(R) Extension for Scikit-learn in your code. You will not get an error if you do this. When you use algorithms or parameters not supported by the extension, the package fallbacks into original stock version of scikit-learn.
- HW: c5.24xlarge AWS EC2 Instance using an Intel Xeon Platinum 8275CL with 2 sockets and 24 cores per socket
- SW: scikit-learn version 0.24.2, scikit-learn-intelex version 2021.2.3, Python 3.8
System Requirements | Install via pip or conda | Build from sources
Intel(R) Extension for Scikit-learn is available at the Python Package Index, on Anaconda Cloud in Conda-Forge channel and in Intel channel. You can also build the extension from sources.
The extension is also available as a part of Intel® AI Analytics Toolkit (AI Kit). If you already have AI Kit installed, you do not need to install the extension.
Installation via pip
package manager is recommended by default:
pip install scikit-learn-intelex
We publish blogs on Medium, so follow us to learn tips and tricks for more efficient data analysis with the help of Intel(R) Extension for Scikit-learn. Here are our latest blogs:
- Save Time and Money with Intel Extension for Scikit-learn
- Superior Machine Learning Performance on the Latest Intel Xeon Scalable Processors
- Leverage Intel Optimizations in Scikit-Learn
- Intel Gives Scikit-Learn the Performance Boost Data Scientists Need
- From Hours to Minutes: 600x Faster SVM
- Improve the Performance of XGBoost and LightGBM Inference
- Accelerate Kaggle Challenges Using Intel AI Analytics Toolkit
- Accelerate Your scikit-learn Applications
- Accelerate Linear Models for Machine Learning
- Accelerate K-Means Clustering
[See answers to frequently asked questions]
No. The patching only affects selected algorithms and their parameters.
In cases when unsupported parameters are used, the package fallbacks into original stock version of scikit-learn. You will not get an error.
If you use algorithms for which no optimizations are available, their original version from the stock scikit-learn is used.
Yes. To find out which implementation of the algorithm is currently used (Intel(R) Extension for Scikit-learn or original Scikit-learn), use the verbose mode.
We compare the performance of Intel(R) Extension for Scikit-Learn to other frameworks in Machine Learning Benchmarks. Read our blogs on Medium if you are interested in the detailed comparison.
If the patching does not cover your scenarios, submit an issue on GitHub with the description of what you would want to have.
Report issues, ask questions, and provide suggestions using:
You may reach out to project maintainers privately at onedal.maintainers@intel.com
Intel(R) Extension for Scikit-learn is part of oneAPI and Intel® AI Analytics Toolkit (AI Kit).
The acceleration is achieved through the use of the Intel(R) oneAPI Data Analytics Library (oneDAL). Learn more: