简体   繁体   English

从scikit-learn中的文件加载决策树

[英]load decision tree from file in scikit-learn

In python scikit learn, there is a method called export_graphviz to export a decision tree to dot file. 在python scikit中,有一个名为export_graphviz的方法可以将决策树导出到点文件。

I want to ask if there is a method to import a dot file to scikit learn as a decision tree? 我想问一下是否有一种方法可以将点文件导入scikit学习作为决策树? like some function called sklearn.tree.import_graphviz() ? 像一些名为sklearn.tree.import_graphviz()的函数?

AFAIK There is no easy way to do that. AFAIK没有简单的方法可以做到这一点。 Graphviz can only be used to visualise the decision tree. Graphviz只能用于可视化决策树。 If you wish to save the model you can use Pickle to save the model. 如果要保存模型,可以使用Pickle保存模型。 For example: 例如:

import cPickle
# save the classifier
with open('my_dumped_classifier.pkl', 'wb') as fid:
    cPickle.dump(gnb, fid)    

# load it again
with open('my_dumped_classifier.pkl', 'rb') as fid:
    gnb_loaded = cPickle.load(fid)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM