python决策树export_python – sklearn.tree.export_graphviz替代品

可以使用pypi中的pydotplus可视化决策树,但它在我的机器上有问题(它表示它不是用libexpat构建的,因此它只显示节点上的数字而不是带有某些信息的表)并且我会喜欢用另一种方法.我已经尝试过使用networkx,但它需要pygraphviz来读取.dot文件并制作它们的网络图.当我尝试使用也失败的pip安装它时.

所以现在我正在寻找一种可视化决策树的替代方法,可以使用pip或anaconda进行安装.

有哪些替代品?

编辑#1

conda列表的输出:

# packages in environment at /home/xiaolong/development/anaconda3/envs/coursera_ml_classification:

#

alabaster 0.7.7 py34_0 defaults

awscli 1.6.2

babel 2.3.3 py34_0 defaults

backports 1.0 py34_0 defaults

backports-abc 0.4

backports.shutil-get-terminal-size 1.0.0

backports_abc 0.4 py34_0 defaults

bcdoc 0.12.2

boto 2.33.0

botocore 0.73.0

cairo 1.12.18 6 defaults

certifi 2015.4.28

colorama 0.2.5

cycler 0.10.0 py34_0 defaults

decorator 4.0.9 py34_0 defaults

docutils 0.12 py34_0 defaults

entrypoints 0.2 py34_1 defaults

expat 2.1.0 0 defaults

fontconfig 2.11.1 5 defaults

freetype 2.5.5 0 defaults

get_terminal_size 1.0.0 py34_0 defaults

glib 2.43.0 2 asmeurer

graphviz 2.38.0 1 defaults

harfbuzz 0.9.39 0 defaults

imagesize 0.7.0 py34_0 defaults

ipykernel 4.3.1 py34_0 defaults

ipython 4.2.0 py34_0 defaults

ipython-genutils 0.1.0

ipython_genutils 0.1.0 py34_0 defaults

ipywidgets 4.1.1 py34_0 defaults

jedi 0.9.0 py34_0 defaults

jinja2 2.8 py34_0 defaults

jmespath 0.5.0

jsonschema 2.5.1 py34_0 defaults

jupyter 1.0.0 py34_2 defaults

jupyter-client 4.2.2

jupyter-console 4.1.1

jupyter-core 4.1.0

jupyter_client 4.2.2 py34_0 defaults

jupyter_console 4.1.1 py34_0 defaults

jupyter_core 4.1.0 py34_0 defaults

libffi 3.2.1 0 defaults

libgcc 5.2.0 0 defaults

libgfortran 3.0.0 1 defaults

libpng 1.6.17 0 defaults

libsodium 1.0.3 0 defaults

libxml2 2.9.2 0 defaults

llvmlite 0.10.0 py34_0 defaults

markupsafe 0.23 py34_0 defaults

matplotlib 1.5.1 np111py34_0 defaults

mistune 0.7.2 py34_0 defaults

mkl 11.3.1 0 defaults

multipledispatch 0.4.8

nbconvert 4.2.0 py34_0 defaults

nbformat 4.0.1 py34_0 defaults

notebook 4.2.0 py34_0 defaults

numpy 1.11.0 py34_0 defaults

openssl 1.0.2h 0 defaults

pandas 0.18.1 np111py34_0 defaults

pango 1.39.0 0 defaults

path.py 8.2.1 py34_0 defaults

pep8 1.7.0 py34_0 defaults

pexpect 4.0.1 py34_0 defaults

pickleshare 0.5 py34_0 defaults

pip 8.1.1 py34_1 defaults

pixman 0.32.6 0 defaults

prettytable 0.7.2

psutil 4.1.0 py34_0 defaults

ptyprocess 0.5 py34_0 defaults

pyasn1 0.1.9

pydotplus 2.0.2 py34_0 file:///home/xiaolong/development/anaconda3/conda-bld/linux-64/pydotplus-2.0.2-py34_0.tar.bz2

pyflakes 1.1.0 py34_0 defaults

pygments 2.1.3 py34_0 defaults

pyparsing 2.1.1 py34_0 defaults

pyqt 4.11.4 py34_1 defaults

python 3.4.4 0 defaults

python-contrib-nbextensions alpha

python-dateutil 2.5.2 py34_0 defaults

pytz 2016.3 py34_0 defaults

pyyaml 3.11

pyzmq 15.2.0 py34_0 defaults

qt 4.8.7 1 defaults

qtconsole 4.2.1 py34_0 defaults

readline 6.2 2 defaults

requests 2.9.1

rope 0.9.4 py34_1 defaults

rope-py3k 0.9.4.post1

rsa 3.1.2

scikit-learn 0.17.1 np111py34_0 defaults

scipy 0.17.0 np111py34_3 defaults

setuptools 20.7.0 py34_0 defaults

sframe 1.8.5

simplegeneric 0.8.1 py34_0 defaults

sip 4.16.9 py34_0 defaults

six 1.10.0 py34_0 defaults

snowballstemmer 1.2.1 py34_0 defaults

sphinx 1.4.1 py34_0 defaults

sphinx-rtd-theme 0.1.9

sphinx_rtd_theme 0.1.9 py34_0 defaults

spyder 2.3.8 py34_1 defaults

sqlite 3.9.2 0 defaults

terminado 0.5 py34_1 defaults

tk 8.5.18 0 defaults

tornado 4.3 py34_0 defaults

traitlets 4.2.1 py34_0 defaults

wheel 0.29.0 py34_0 defaults

xz 5.0.5 1 defaults

zeromq 4.1.3 0 defaults

zlib 1.2.8 0 defaults

SciPy版本:0.17.0

digraph Tree {

node [shape=box, style="filled", color="black"] ;

0 [label="grade.B <= 0.5\ngini = 0.5\nsamples = 37224\nvalue = [18476, 18748]", fillcolor="#399de504"] ;

1 [label="grade.C <= 0.5\ngini = 0.4973\nsamples = 32094\nvalue = [17218, 14876]", fillcolor="#e5813923"] ;

0 -> 1 [labeldistance=2.5, labelangle=45, headlabel="True"] ;

2 [label="gini = 0.4829\nsamples = 21728\nvalue = [12875, 8853]", fillcolor="#e5813950"] ;

1 -> 2 ;

3 [label="gini = 0.4869\nsamples = 10366\nvalue = [4343, 6023]", fillcolor="#399de547"] ;

1 -> 3 ;

4 [label="grade.A <= 14.8301\ngini = 0.3702\nsamples = 5130\nvalue = [1258, 3872]", fillcolor="#399de5ac"] ;

0 -> 4 [labeldistance=2.5, labelangle=-45, headlabel="False"] ;

5 [label="gini = 0.3555\nsamples = 4987\nvalue = [1153, 3834]", fillcolor="#399de5b2"] ;

4 -> 5 ;

6 [label="gini = 0.3902\nsamples = 143\nvalue = [105, 38]", fillcolor="#e58139a3"] ;

4 -> 6 ;

}

编辑#2

我在Jupyter笔记本中对此进行了编程,但如果您尝试使用以下方法显示SVG,则会出现不对svg着色的错误:

![Decision Tree]('dtree.svg')

我找到了一个解决方法here:

from IPython.display import HTML

svg = None

with open('dtree.svg') as svg_file:

svg = svg_file.read()

HTML(svg)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值