use*_*725 11 python random-forest scikit-learn
我已经使用非常大的数据集训练了一个来自Python Sckit Learn Module的RandomForestClassifier,但问题是我怎么可能保存这个模型并让其他人在它们的末尾应用它.谢谢!
EdC*_*ica 24
建议的方法是使用joblib,这将导致比pickle小得多的文件:
from sklearn.externals import joblib
joblib.dump(clf, 'filename.pkl')
#then your colleagues can load it
clf = joblib.load('filename.pkl')
Run Code Online (Sandbox Code Playgroud)
查看在线文档
您是否尝试过RandomForestClassifier使用 Pickle 模块进行酸洗,然后将其保存到磁盘?
Here\xe2\x80\x99s 是一个基于pickle文档的示例:
\n\nimport pickle\n\nclassifier = RandomForestClassifier(etc)\noutput = open(\'classifier.pkl\', \'wb\')\npickle.dump(classifier, output)\noutput.close()\nRun Code Online (Sandbox Code Playgroud)\n\n\xe2\x80\x9cother people\xe2\x80\x9d 然后可以重新加载 pickled 对象,如下所示:
\n\nimport pickle\n\nf = open(\'classifier.pkl\', \'rb\')\nclassifier = pickle.load(f)\nf.close()\nRun Code Online (Sandbox Code Playgroud)\n