pycharm - 在 PyCharm 中可视化点文件

标签 pycharm graphviz dot

我已经生成了一个点文件来使用代码可视化决策树

import numpy as np
from sklearn.model_selection import train_test_split
import sklearn.tree
from sklearn.datasets import load_breast_cancer

cancer = load_breast_cancer()
X_train, X_test, y_train, y_test =train_test_split(cancer.data,cancer.target, stratify=cancer.target, random_state=42)
tree = sklearn.tree.DecisionTreeClassifier(random_state=0,max_depth=4)
tree.fit(X_train,y_train)
sklearn.tree.export_graphviz(tree,out_file="tree.dot",class_names=cancer.target_names,feature_names=cancer.feature_names,impurity=False, filled=True)

这成功地创建了 tree.dot 文件。我现在可以使用 graphviz ( https://graphviz.gitlab.io/_pages/Download/Download_windows.html ) 的 dot.exe 实用程序生成一个 png 文件

from subprocess import check_call
check_call(['...PATH_TO_GRAPHVIZ/graphviz-2.38/release/bin/dot.exe','-Tpng','tree.dot','-o','tree.png'])

我也想在 PyCharm 中可视化决策树。有没有办法做到这一点?

最佳答案

你可以安装bzixilu的dotplugin插件,
当您打开点文件时,图表将自动显示在它旁边

关于pycharm - 在 PyCharm 中可视化点文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52352836/

相关文章:

python - 在 OS X Lion 的 pycharm 中使用 emacs 绑定(bind)

python - 可视化代码的架构

python 2.7.9/pycharm 4/windows7 : 'file' object has no attribute 'readall'

graphviz - 仅在 graphviz 中显示唯一的边

graphviz - Graphviz 中的左->右、下、右->左、下、左->右布局

drawing - 如何绘制超图?

environment-variables - Doxygen for Windows 中 DOT 路径的环境变量

python - Mac 上的 wxPython 和 PyCharm

linux - Graphviz 找不到任何字体

c++ - 无法使用点布局(graphviz 作为库)