win64 python pydot安装配置
来源:互联网 发布:淘宝购物返利网高 编辑:程序博客网 时间:2024/06/05 19:55
本文主要是win10,下面anaconda安装pydot以及 .dot文件转化为png。
1. 安装pydot
pip install pydot
2. 安装GraphViz
链接如下:
http://www.graphviz.org/Download_windows.php
下载完成点击安装,选择好安装目录之后即可。最终将安装路径添加到,环境变量中。
3. 重启pycharm
from sklearn.datasets import load_irisfrom sklearn import treefrom sklearn.tree import DecisionTreeClassifier, export_graphvizimport subprocessimport pydotclf = tree.DecisionTreeClassifier()iris = load_iris()clf = clf.fit(iris.data, iris.target)tree.export_graphviz(clf, out_file='tree.dot')(graph,) = pydot.graph_from_dot_file('tree.dot')graph.write_png('somefile.png')
生成下面的tree
from sklearn.datasets import load_irisfrom sklearn import treefrom sklearn.tree import DecisionTreeClassifier, export_graphvizimport subprocessimport pydotdef visualize_tree(tree): """Create tree png using graphviz. Args ---- tree -- scikit-learn DecsisionTree. feature_names -- list of feature names. """ with open("tree.dot", 'w') as f: export_graphviz(tree, out_file=f, feature_names=iris.feature_names) command = ["dot", "-Tpng", "tree.dot", "-o", "dt.png"] try: subprocess.check_call(command) except: exit("Could not run dot, ie graphviz, to " "produce visualization")clf = tree.DecisionTreeClassifier()iris = load_iris()clf = clf.fit(iris.data, iris.target)tree.export_graphviz(clf, out_file='tree.dot')visualize_tree(clf)
这个可视化,添加了属性,看起来更直观
转载注明出处,并在下面留言!!!
阅读全文
0 0
- win64 python pydot安装配置
- python pydot安装
- Python pydot模块安装
- python的数据可视化 graphviz pydot安装配置(win10)
- python的数据可视化 graphviz pydot安装配置(win10)
- win64 安装Python+pip
- python数据可视化pydot的安装
- python笔记 --pydot安装与绘制决策树
- win64位 安装python opencv
- win64 python安装PIL出错
- win64+php+memcache安装配置
- 配置pydot环境
- theano中的pydot安装
- Win64位下Python环境的安装
- win64 Python下安装PIL出错解决
- python PIL的win64安装经验
- win64下python安装PIL出错
- python-安装easy_install和pip(win64位)
- 在framework下新建系统api
- JVM -XX:NewRatio、-XX:SurvivorRatio参数含义
- JavaScript 事件流、事件处理程序及事件对象总结
- 【图论】欧拉路
- EnumHelper.cs
- win64 python pydot安装配置
- 学习java第27天,str.equals();
- linux线程资源回收方法
- Fragment跳转到Activity,刚跳转就走了onActivityResult方法
- 图片的二次采样
- [高等数学]微分方程
- vue-cli创建的项目不需要再创建webpack-config.js文件,因为已经配置过了
- JavaScript框架之AngularJS学习——UIRouter
- CSS hack是什么?IE6\7\8\9\10浏览器的CSS hack大全介绍