pydot

AttributeError: 'list' object has no attribute 'create_png'

…衆ロ難τιáo~ 提交于 2020-01-02 12:46:29
问题 This classifies the data as a decision tree. The decision tree is created but I am not able to view the decision tree. import numpy as np from sklearn import linear_model, datasets, tree import matplotlib.pyplot as plt iris = datasets.load_iris() f = open('decision_tree_data.txt') x_train = [] y_train = [] for line in f: line = np.asarray(line.split(),dtype = np.float32) x_train.append(line[:-1]) y_train.append(line[:-1]) x_train = np.asmatrix(x_train) y_train = np.asmatrix(y_train) model =

AttributeError: 'list' object has no attribute 'create_png'

笑着哭i 提交于 2020-01-02 12:46:06
问题 This classifies the data as a decision tree. The decision tree is created but I am not able to view the decision tree. import numpy as np from sklearn import linear_model, datasets, tree import matplotlib.pyplot as plt iris = datasets.load_iris() f = open('decision_tree_data.txt') x_train = [] y_train = [] for line in f: line = np.asarray(line.split(),dtype = np.float32) x_train.append(line[:-1]) y_train.append(line[:-1]) x_train = np.asmatrix(x_train) y_train = np.asmatrix(y_train) model =

pydot and graphviz error: Couldn't import dot_parser, loading of dot files will not be possible

守給你的承諾、 提交于 2019-12-27 16:23:45
问题 When I run a very simple code with pydot import pydot graph = pydot.Dot(graph_type='graph') for i in range(3): edge = pydot.Edge("king", "lord%d" % i) graph.add_edge(edge) vassal_num = 0 for i in range(3): for j in range(2): edge = pydot.Edge("lord%d" % i, "vassal%d" % vassal_num) graph.add_edge(edge) vassal_num += 1 graph.write_png('example1_graph.png') It prints me the error message: Couldn't import dot_parser, loading of dot files will not be possible. I'm using python 2.7.3 回答1: Answer

Is there a way to control line angle when producing graphs with pyDot

走远了吗. 提交于 2019-12-24 13:17:16
问题 I wrote a python class to display and animate binary search trees. Yet the graphs produced by the pyDot edge and node commands don't seem to allow me to control the angle or direction of the arrows connecting each element of my tree. There are lots of controls for shape of the nodes but there does not seem to be any control for angle of the lines. I was hoping to find some kind of minimum angle parameter to add to my edges as they are added to the graph? This is a sample of my code where I

GraphViz's executables not found - Why are there no executables installed after installation of graphViz via pip?

社会主义新天地 提交于 2019-12-24 06:35:37
问题 I installed pydotplus and graphviz in an virtual environment (Windows 8.1). Now I want to visualize a decision tree. However pydotplus is not able to find GraphViz's executables. from sklearn import tree from sklearn.datasets import load_iris import pydotplus from IPython.display import Image iris = load_iris() X,y = iris.data[:,2:], iris.target clf = tree.DecisionTreeClassifier(max_depth=2) clf.fit(X,y) dot_data = tree.export_graphviz(clf, out_file=None, feature_names=iris.feature_names[2:],

Why won't pip install the current version of a package?

时光毁灭记忆、已成空白 提交于 2019-12-21 20:14:57
问题 I can't get pip to install the current version of pydot (1.0.28). Though yolk and PyPi both report this version as the available, current one, pip -U pydot gives me Requirement already up-to-date: pydot in /Library/Python/2.7/site-packages Requirement already up-to-date: pyparsing in /Library/Python/2.7/site-packages (from pydot) Requirement already up-to-date: setuptools in /Library/Python/2.7/site-packages (from pydot) forcing the current version with pip -U pydot ==1.0.28 gives me

Color of the node of tree with graphviz using class_names

喜你入骨 提交于 2019-12-20 02:15:38
问题 Expanding on a prior question: Changing colors for decision tree plot created using export graphviz How would I color the nodes of the tree bases on the dominant class (species of iris), instead of a binary distinction? This should require a combination of the iris.target_names, the string describing the class, and iris.target, the class. import pydotplus from sklearn.datasets import load_iris from sklearn import tree import collections clf = tree.DecisionTreeClassifier(random_state=42) iris

How can I use conda to install pydot?

两盒软妹~` 提交于 2019-12-17 10:33:41
问题 Trying to generate some PDF's of decision trees by following some of the sklearn documentation, but can't get Pydot on my machine. Is there any way to use the conda installer to install the pydot package? Based on the command line errors I'm seeing, it may be a 64bit issue. I use binstar search to find the package channel: C:\binstar search -t conda Which gives the recommendation of looking at the packages in detail using binstar show j14r/pydot Which then tells me to conda install --channel

Rendering a tree in python with Anytree and graphviz. Can't open file

丶灬走出姿态 提交于 2019-12-14 02:14:21
问题 This question is based on Tarun's Answer for rendering a tree in python using anytree and graphviz: https://stackoverflow.com/a/49442969/2139007 After installing graphviz and adding it to my PATH variables i'am trying to run the following python code: DotExporter(nodes[0]["a"], nodeattrfunc=lambda node: 'label="{}"'.format(node.display_name)).to_picture("tree.png") The above code generates the following error: Error: dot: can't open C:\Users\username\AppData\Local\Temp\tmpa7t554le Traceback

Parsing comments in dot file with python

拜拜、爱过 提交于 2019-12-13 02:27:48
问题 I'm using pydot for parsing dot files in python. I can't find a way to parse comments present in the dot file itself, is there any way to do it? By just looking at the documentation I couldn't find any answer. Also, would you suggest a better parser for dot files (perhaps better maintained) than pydot ? Thanks 回答1: it is possible if you use the module json along with it like: import pydot import pyparsing import json graph = pydot.graph_from_dot_file(path) edgeList = graph.get_edge_list() for