当前位置:网站首页>Does sklearex make your sklearn machine learning model training fly fast?
Does sklearex make your sklearn machine learning model training fly fast?
2022-06-25 12:17:00 【Yetingyun】
One 、 introduction
scikit-learn As a classic machine learning framework , It has developed for more than ten years since its birth , It is simple and easy to use API Deeply loved by users (fit()、predict()、transform() etc. ), Other machine learning frameworks will more or less learn from . But its computing speed has been widely criticized by users . be familiar with scikit-learn Your friends should know ,scikit-learn Some of the included in are based on joblib The effect of the operation acceleration function of the library is limited , Can't make full use of computing power .
Today I'd like to share with you a skill , It can help us without changing the original code , Get tens or even thousands of times scikit-learn The computing efficiency is improved .
Two 、 utilize sklearnex Speed up scikit-learn
In order to speed up the calculation , You just need to add sklearnex This library , Can help us to have Intel On the processor's device , The operation efficiency is greatly improved .
This newer Library , It's best to create a clean conda Experiment in virtual environment ( To avoid some dependent library versions from following Base Conflict in the environment , More unnecessary trouble ) All orders are as follows , We installed it by the way jupyterlab As IDE:
conda create -n sklearnex python=3.8
conda activate sklearnex
conda install jupyter
conda install nb_conda
pip install scikit-learn scikit-learn-intelex -i http://pypi.douban.com/simple --trusted-host pypi.douban.com After the preparation of the experimental environment , stay jupyter notebook Write test code in to see how the acceleration effect , It's easy to use , Just import... Into the code scikit-learn Before the relevant functional modules , Just run the following code :
from sklearnex import patch_sklearn, unpatch_sklearn
patch_sklearn()After the acceleration mode is successfully turned on, the following information will be printed :
The other thing to do is to put your original scikit-learn The code can be executed later , I did a simple test on my old ASUS notebook, which I usually study and write code .
With K-Means Clustering as an example , On a sample dataset with a sample size of 100000 , It only takes... After acceleration is turned on 46.84 Seconds to complete the training set , While using unpatch_sklearn() After the acceleration mode is forced off ( Be careful scikit-learn Relevant modules need Re import ), The training time increases to 100.52 second , Means through sklearnex We got 2 Multiple times of operation speed .
give the result as follows :
And according to the official statement , The stronger CPU A higher percentage of performance improvements can be achieved ( I'm the only one running here exampls Look at , old Intel CPU The acceleration is not enough ), The following figure shows the official Intel Xeon Platinum 8275CL The performance improvement results after testing a series of algorithms under the processor , It can not only improve the training speed , It can also improve the speed of model reasoning and prediction , In some cases, it even reaches Thousands of times Performance improvement of :
Officials also offer some ipynb Example :https://github.com/intel/scikit-learn-intelex/tree/master/examples/notebooks
It shows that K-means、DBSCAN、 Random forests 、 Logical regression 、 Ridge return And other common models , Interested readers can consult and learn by themselves .
Besides , Can also accelerate sklearn stay GPU Performance on , The method of use is similar to :
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)Refer to the :
边栏推荐
- Arm V7 continuous load / store
- confluence7.4. X upgrade record
- 做自媒体视频需要怎么做才能年收入一百万?
- Mui scroll bar recovery
- An easy-to-use seal design tool - (can be converted to ofd file)
- . Using factory mode in net core
- R语言使用nnet包的multinom函数构建无序多分类logistic回归模型、使用epiDisplay包的lrtest函数执行多个模型似然比检验对比两个模型的性能是否有差异
- Encapsulation of practical methods introduced by webrtc native M96 basic base module (MD5, Base64, time, random number)
- Real software developers will use this method to predict the future
- Le détour d'un ingénieur en matériel
猜你喜欢
随机推荐
学习笔记 2022 综述 | 自动图机器学习,阐述 AGML 方法、库与方向
Caused by: org. xml. sax. SAXParseException; lineNumber: 1; columnNumber: 10; Processing matching '[xx][mm][ll]' is not allowed
客户经理的开户二维码开户买股票安全吗?有谁知道啊
Kotlin study notes
VFP serial port communication is difficult for 9527. Maomao just showed his skill and was defeated by kiss
黑马畅购商城---3.商品管理
属性分解 GAN 复现 实现可控人物图像合成
How can we make an annual income of onemillion yuan by making our own media video?
网络 | traceroute,路由跟踪命令,用于确定 IP 数据包访问目标地址所经过的路径。
刷入Magisk通用方法
Kotlin Foundation
Dark horse shopping mall ---2 Distributed file storage fastdfs
Arm V7 continuous load / store
R language dplyr package summary_ The at function calculates the count number, mean and median of multiple data columns (specified by vectors) in the dataframe data, and specifies na RM parameter, spe
一套自动化无纸办公系统(OA+审批流)源码:带数据字典
devsecops与devops的理解与建设
Dark horse shopping mall ---8 Microservice gateway and JWT token
ARM V7 ldr str 内存访问
使用php脚本查看已开启的扩展
Mui scroll bar recovery









