【问题标题】:Drawing Decision tree with python用python画决策树
【发布时间】:2020-02-26 04:26:48
【问题描述】:

我正在使用 python 绘制决策树,

tree.plot_tree(clf.fit(X_train, y_train))
plt.suptitle("Decision surface of a decision tree using paired features")
plt.show()

但是当我运行这段代码时,树会像这样显示

决策树

有什么办法可以让树正常吗?

【问题讨论】:

  • 您是否尝试过更改某些选项,例如字体大小?

标签: python matplotlib scikit-learn decision-tree


【解决方案1】:

export_graphviz 对您来说可能是一个不错的选择。

这里有一个Kaggle notebook,它解释了如何充分利用 sklearn 提供的这个功能。

对于您正在使用的 plot_tree 函数,您可以尝试使用 fontsize 参数更改字体大小。或者,如果您还没有这样做,您也可以尝试更改图形的大小 -

fig = matplotlib.pyplot.gcf()
fig.set_size_inches(x, y) #dimensions you want

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-03-12
    • 2021-08-19
    • 2016-11-09
    • 2018-09-06
    • 2019-01-14
    • 2015-09-21
    • 2021-08-23
    • 2018-09-05
    相关资源
    最近更新 更多