https://github.com/uxlfoundation/scikit-learn-intelex
Extension for Scikit-learn is a seamless way to speed up your Scikit-learn application
https://github.com/uxlfoundation/scikit-learn-intelex
ai-inference ai-machine-learning ai-training analytics big-data data-analysis gpu machine-learning machine-learning-algorithms oneapi python scikit-learn swrepo
Last synced: 10 days ago
JSON representation
Extension for Scikit-learn is a seamless way to speed up your Scikit-learn application
- Host: GitHub
- URL: https://github.com/uxlfoundation/scikit-learn-intelex
- Owner: uxlfoundation
- License: apache-2.0
- Created: 2018-08-07T06:45:41.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2025-04-18T10:42:08.000Z (15 days ago)
- Last Synced: 2025-04-18T18:40:28.793Z (15 days ago)
- Topics: ai-inference, ai-machine-learning, ai-training, analytics, big-data, data-analysis, gpu, machine-learning, machine-learning-algorithms, oneapi, python, scikit-learn, swrepo
- Language: Python
- Homepage: https://uxlfoundation.github.io/scikit-learn-intelex/
- Size: 35.3 MB
- Stars: 1,272
- Watchers: 24
- Forks: 182
- Open Issues: 88
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
- Support: SUPPORT.md
Awesome Lists containing this project
README
# Extension for Scikit-learn*
Speed up your scikit-learn applications for CPUs and GPUs across single- and multi-node configurations
[Releases](https://github.com/uxlfoundation/scikit-learn-intelex/releases) | [Documentation](https://uxlfoundation.github.io/scikit-learn-intelex/) | [Examples](https://github.com/uxlfoundation/scikit-learn-intelex/tree/master/examples/notebooks) | [Support]() | [License](https://github.com/uxlfoundation/scikit-learn-intelex/blob/master/LICENSE)
[](https://dev.azure.com/daal/daal4py/_build/latest?definitionId=9&branchName=main)
[](https://scan.coverity.com/projects/daal4py)
[](https://github.com/uxlfoundation/scikit-learn-intelex/discussions)
[](https://pypi.org/project/scikit-learn-intelex/)
[](https://anaconda.org/conda-forge/scikit-learn-intelex)
[](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue)
[](https://img.shields.io/badge/sklearn-1.0%20%7C%201.2%20%7C%201.3%20%7C%201.4%20%7C%201.5%20%7C%201.6-blue)---
## Overview
Extension for Scikit-learn is a **free software AI accelerator** designed to deliver over **10-100X** acceleration to your existing scikit-learn code.
The software acceleration is achieved with vector instructions, AI hardware-specific memory optimizations, threading, and optimizations.With Extension for Scikit-learn, you can:
* Speed up training and inference by up to 100x with equivalent mathematical accuracy
* Benefit from performance improvements across different CPU hardware configurations, including GPUs and multi-GPU configurations
* Integrate the extension into your existing Scikit-learn applications without code modifications
* Continue to use the open-source scikit-learn API
* Enable and disable the extension with a couple of lines of code or at the command line## Acceleration

[Benchmarks code](https://github.com/IntelPython/scikit-learn_bench)
## Optimizations
Easiest way to benefit from accelerations from the extension is by patching scikit-learn with it:
- **Enable CPU optimizations**
```python
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 GPU optimizations**
_Note: executing on GPU has [additional system software requirements](https://www.intel.com/content/www/us/en/developer/articles/system-requirements/intel-oneapi-dpcpp-system-requirements.html) - see [details](https://uxlfoundation.github.io/scikit-learn-intelex/latest/oneapi-gpu.html)._
```python
import numpy as np
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)
```:eyes: Check out available [notebooks](https://github.com/uxlfoundation/scikit-learn-intelex/tree/master/examples/notebooks) for more examples.
### Usage without patching
Alternatively, all functionalities are also available under a separate module which can be imported directly, without involving any patching.
* To run on CPU:
```python
import numpy as np
from sklearnex.cluster import DBSCANX = 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)
```* To run on GPU:
```python
import numpy as np
from sklearnex import config_context
from sklearnex.cluster import DBSCANX = 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)
```## Installation
To install Extension for Scikit-learn, run:
```shell
pip install scikit-learn-intelex
```Package is also offered through other channels such as conda-forge. See all installation instructions in the [Installation Guide](https://github.com/uxlfoundation/scikit-learn-intelex/blob/main/INSTALL.md).
## Integration
The easiest way of accelerating scikit-learn workflows with the extension is through through [patching](https://uxlfoundation.github.io/scikit-learn-intelex/latest/quick-start.html#patching), which replaces the stock scikit-learn algorithms with their optimized versions provided by the extension using the same namespaces in the same modules as scikit-learn.
The patching only affects [supported algorithms and their parameters](https://uxlfoundation.github.io/scikit-learn-intelex/latest/algorithms.html).
You can still use not supported ones in your code, the package simply fallbacks into the stock version of scikit-learn.> **_TIP:_** Enable [verbose mode](https://uxlfoundation.github.io/scikit-learn-intelex/latest/verbose.html) to see which implementation of the algorithm is currently used.
To patch scikit-learn, you can:
* Use the following command-line flag:
```shell
python -m sklearnex my_application.py
```
* Add the following lines to the script:
```python
from sklearnex import patch_sklearn
patch_sklearn()
```:eyes: Read about [other ways to patch scikit-learn](https://uxlfoundation.github.io/scikit-learn-intelex/latest/quick-start.html#patching).
As an alternative, accelerated classes from the extension can also be imported directly without patching, thereby allowing to keep them separate from stock scikit-learn ones - for example:
```python
from sklearnex.cluster import DBSCAN as exDBSCAN
from sklearn.cluster import DBSCAN as stockDBSCAN# ...
```## Documentation
* [Quick Start](https://uxlfoundation.github.io/scikit-learn-intelex/latest/quick-start.html)
* [Documentation and Tutorials](https://uxlfoundation.github.io/scikit-learn-intelex/latest/index.html)
* [Release Notes](https://github.com/uxlfoundation/scikit-learn-intelex/releases)
* [Medium Blogs](https://uxlfoundation.github.io/scikit-learn-intelex/latest/blogs.html)
* [Code of Conduct](https://github.com/uxlfoundation/scikit-learn-intelex/blob/master/CODE_OF_CONDUCT.md)### Extension and oneDAL
Acceleration in patched scikit-learn classes is achieved by replacing calls to scikit-learn with calls to oneDAL (oneAPI Data Analytics Library) behind the scenes:
- [oneAPI Data Analytics Library](https://github.com/uxlfoundation/oneDAL)## Samples & Examples
* [Examples](https://github.com/uxlfoundation/scikit-learn-intelex/tree/master/examples/notebooks)
* [Samples](https://uxlfoundation.github.io/scikit-learn-intelex/latest/samples.html)
* [Kaggle Kernels](https://uxlfoundation.github.io/scikit-learn-intelex/latest/kaggle.html)## How to Contribute
We welcome community contributions, check our [Contributing Guidelines](https://github.com/uxlfoundation/scikit-learn-intelex/blob/master/CONTRIBUTING.md) to learn more.
------------------------------------------------------------------------
\* The Intel logo, and other Intel marks are trademarks of Intel Corporation or its subsidiaries. Other names and brands may be claimed as the property of others.