【发布时间】:2023-01-30 23:40:06
【问题描述】:
我正在尝试使用 pydot 函数 graph_from_dot_data 创建决策树的图像。一切正常,但生成的图像在根节点旁边有一个空节点。可重现的例子 -
from sklearn.datasets import load_iris
from sklearn import tree
import pydot
from IPython.display import Image
clf = DecisionTreeClassifier()
iris = load_iris()
clf = clf.fit(iris.data, iris.target)
graph = graph_from_dot_data(export_graphviz(clf))
Image(graph[0].create_png())
如何在根节点旁边没有空节点的情况下生成决策树图像?
【问题讨论】: