如何输出sklearn standardscaler [英] How to output sklearn standardscaler

查看:40
本文介绍了如何输出sklearn standardscaler的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 preprocessing.standardscaler 在 sklearn 中标准化了我的数据.问题是如何将其保存在本地以备后用?

I have standardized my data in sklearn using preprocessing.standardscaler. Question is how could I save this in my local for latter use?

谢谢

推荐答案

如果我理解正确,您想保存训练好的模型以便再次加载正确吗?

If I understand you correctly you want to save your trained model so it can be loaded again correct?

有两种方法,一种是使用python的pickle,另一种是使用joblib.推荐的方法是 joblib 因为这将导致文件比泡菜小得多,泡菜会转储对象的字符串表示:

There are two methods, using python's pickle and the other method which is to use joblib. The recommend method is joblib as this will result in a much smaller file than a pickle, which dumps a string representation of your object:

from sklearn.externals import joblib
joblib.dump(clf, 'filename.pkl') 

#then load it later, remember to import joblib of course

clf = joblib.load('filename.pk1')

请参阅在线文档

注意:sklearn.externals.joblib 已弃用.安装并使用纯 joblib 代替

Note: sklearn.externals.joblib is deprecated. Install and use the pure joblib instead

这篇关于如何输出sklearn standardscaler的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆