Member-only story
Speed up SkLearn Model Training by 10 or 100X… by just adding 2 lines of Code
Scikit-learn is a widely used machine learning library. It contains a number of algorithms that we can use for classification, regression, clustering, etc. Sometimes it can be slow to train a sklearn model for a huge dataset. This post will show you how to use the Intel Scikit-learn extension to speed up the training and inference time.
Scikit-Learn-Intelex is an sklearn extension created by Intel to speed up the library performance on Intel CPU, without changing the existing code. The extension provides up to 100++ times speed up on model training and inference, depends on the algorithm, as shown in the image below:
Let’s try the library to verify the claimed performance improvement. First create a virtual environment and then install the library:
pip install scikit-learn-intelex
We will use random forest regressor for the testing. To use the sklearn intel extension, we need to run patch the extension before importing the algorithm:
from sklearnex import patch_sklearn
patch_sklearn()
# After patch_sklearn() then we import the random forest…