Sklearn - 没有 pkl 文件的模型持久性 [英] Sklearn - model persistence without pkl file

查看:70
本文介绍了Sklearn - 没有 pkl 文件的模型持久性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有兴趣保存在 Sklearn 中创建的模型(例如 EmpiricalCovariance、MinCovDet 或 OneClassSVM)并稍后重新应用.我熟悉保存 PKL 文件和 joblib 的选项,但是我更愿意显式保存模型而不是序列化的 python 对象.这样做的主要动机是它可以轻松查看模型参数.

I'm interested in saving the model created in Sklearn (e.g., EmpiricalCovariance, MinCovDet or OneClassSVM) and re-applying later on. I'm familiar with the option of saving a PKL file and joblib, however I would prefer to save the model explicitly and not a serialized python object. The main motivation for this is that it allows easily viewing the model parameters.

我找到了一个关于这样做的参考:http://thiagomarzagao.com/2015/12/07/model-不带泡菜的持久性/

I found one reference to doing this: http://thiagomarzagao.com/2015/12/07/model-persistence-without-pickles/

问题是:随着时间的推移,我可以指望这个工作吗(即 sklearn 的新版本)?这是否过于hacky"解决方案?

The question is: Can I count on this working over time (i.e., new versions of sklearn)? Is this too much of a "hacky" solution?

有人有这方面的经验吗?

Does anyone have experience doing this?

谢谢乔纳森

推荐答案

我不认为这是一个hacky的解决方案,一位同事做过类似的事情,他导出了一个用golang编写的计分器使用的模型,并且比 scikit-learn 评分器快得多.如果您担心与 sklearn 未来版本的兼容性,您应该考虑使用像 condavirtualenv 这样的环境管理器;无论如何,这只是良好的软件工程实践,无论如何您都应该开始习惯.

I don't think it's a hacky solution, a colleague has done a similar thing where he exports a model to be consumed by a scorer which is written in golang, and is much faster than the scikit-learn scorer. If you're worried about compatability with future versions of sklearn, you should consider using an environment manager like conda or virtualenv; in anycause this is just good software engineering practice and something you should start to get used to anyway.

这篇关于Sklearn - 没有 pkl 文件的模型持久性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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