编辑 scikit-learn 决策树 [英] Edit scikit-learn decisionTree

查看:56
本文介绍了编辑 scikit-learn 决策树的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编辑sklearn决策树,例如改变条件或切割节点/叶子等

I would like to edit sklearn decisionTree, e.g. change conditions or cut node/leaf etc.

但似乎没有功能可以做到这一点,如果我可以导出到文件,请对其进行编辑以导入.

But there seems to be no functions to do that, if I could export to a file, edit it to import.

如何编辑决策树?

环境:

  • Windows10
  • python3.3
  • sklearn 0.17.1

推荐答案

即使文档说 DecisionTreeClassifiersplitter kwarg 是一个字符串,你也可以给它还有一个班级.证据:

Even though the docs say that the splitter kwarg for DecisionTreeClassifier is a string, you could give it a class as well. Evidence:

https://github.com/scikit-learn/scikit-learn/blob/412996f/sklearn/tree/tree.py#L353-L360

看起来您可以子类化此处找到的 Splitter 类之一:

Looks like you could subclass one of the Splitter classes found here:

https://github.com/scikit-learn/scikit-learn/blob/0.17.X/sklearn/tree/_splitter.pyx

然后做:

my_decision_tree = sklearn.tree.DecisionTreeClassifier(splitter=mySplitter)

这篇关于编辑 scikit-learn 决策树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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