如何在评估时强制决策树仅使用整数

我正在做一个决策树,我想强制算法仅以整数来评估条件。我正在使用的功能是离散的和整数的,因此树显示“ X 是没有意义的,因此在此示例中,我希望树显示在框中,“ X 或“ X 中的等效项之一。

我需要这样做,以使非技术人员更容易理解树。播放“少于15.5首歌曲” 没有任何意义,它应该少于 43 42

如何在评估时强制决策树仅使用整数

我尝试更改源表的列的类型,它们都为int64,并且问题仍然存在。

我正在使用的代码:

clf = tree.DecisionTreeclassifier(criterion='gini',max_depth=2,splitter='best')

clf = clf.fit(users_data,users_target)

到目前为止,我在文档中没有找到任何参数或类似内容。

谢谢!

zjtw212 回答:如何在评估时强制决策树仅使用整数

首先,我不会自己调整树规则,而是会调整情节。

sklearn还有一个额外的https://localhost//ControlPanel/SingleSignOn/Settings/ValidationConfirmation?culture=en-us&cultureCustomDirectory=。 经过此调整:

precision : int,optional (default=3)

    Number of digits of precision for floating point in the values of impurity,threshold and value attributes of each node.

您可以更改它,例如:

tree.plot_tree(clf,precision=0)

应该给你四舍五入的数字。

本文链接:https://www.f2er.com/3138145.html

大家都在问