【发布时间】:2020-09-22 03:44:39
【问题描述】:
下图中的这个问题。 在 Windows 10 操作系统中。 和 jupyter 笔记本。 和版本 python 3.8。 使用 graphviz 创建图像。
在红色标记的地方。 它应该显示一个更大的迹象。 在 jupyter notebook 中编写 python 代码。
import sklearn.datasets as datasets
import pandas as pd
import numpy as np
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split
from sklearn.externals.six import StringIO
from IPython.display import Image
from sklearn.tree import export_graphviz
import pydotplus
dtree=DecisionTreeClassifier(max_depth=2)
dtree.fit(X_train,y_train)
dot_data = StringIO()
export_graphviz(dtree, out_file=dot_data, filled=True, rounded=True,
special_characters=True, feature_names=X_train.columns)
graph = pydotplus.graph_from_dot_data(dot_data.getvalue())
Image(graph.create_png())
请帮帮我。
【问题讨论】:
标签: python python-3.x jupyter-notebook graphviz