在 Jupyter 中显示 DT 的操作如下:
# Display in jupyter notebook
from IPython.display import Image
Image(filename = 'tree.png')
如何在 anaconda 中看到 DT?
在 Jupyter 中显示 DT 的操作如下:
# Display in jupyter notebook
from IPython.display import Image
Image(filename = 'tree.png')
如何在 anaconda 中看到 DT?
有一种更简单的方法,但有时它首先不起作用,你应该像这样调用你的方法
tree_clf=tree.DecisionTree()
然后你可以为它选择一个名字和路径,让其他人保持和我一样,它看起来像:
from sklearn.tree import export_graphviz
export_graphviz(
tree_clf,
out_file=image_path("iris_tree.dot"),
feature_names=iris.feature_names[2:],
class_names=iris.target_names,
rounded=True,
filled=True
)
希望对你有帮助