decision-tree

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 =

Trouble installing graphviz for python3 on ubuntu 14.04

ⅰ亾dé卋堺 提交于 2020-01-02 09:06:14
问题 I want to draw a decision tree with python3. Yet I can only find modules for python2: graphviz , ete3 Did I miss something? Can I use them with python3? Do you know any other possibilities? I use Ubuntu 14.04. Edit: I tried the command sudo python3 -m pip install graphviz , but it still can't find the module. 回答1: According to Graphviz's PyPI page, it is available for Python 3. On Ubuntu make sure you have graphviz with: sudo apt-get install python3-pygraphviz Perhaps Python3 can't find your

Trouble installing graphviz for python3 on ubuntu 14.04

不羁的心 提交于 2020-01-02 09:05:03
问题 I want to draw a decision tree with python3. Yet I can only find modules for python2: graphviz , ete3 Did I miss something? Can I use them with python3? Do you know any other possibilities? I use Ubuntu 14.04. Edit: I tried the command sudo python3 -m pip install graphviz , but it still can't find the module. 回答1: According to Graphviz's PyPI page, it is available for Python 3. On Ubuntu make sure you have graphviz with: sudo apt-get install python3-pygraphviz Perhaps Python3 can't find your

Need guidance towards evaluative boolean logic tree

我与影子孤独终老i 提交于 2019-12-31 17:45:56
问题 I can't seem to find a pointer in the right direction, I am not even sure what the terms are that I should be researching but countless hours of googling seem to be spinning me in circles, so hopefully the collective hive of intelligence of Stack Overflow can help. The problem is this, I need a way to filter data in what I can only call a compound logic tree. Currently the system implements a simple AND filtering system. For example, lets say we have a dataset of people. You add a bunch of

rpart - Find number of leaves that a cp value to pruning a tree would return

萝らか妹 提交于 2019-12-31 07:42:23
问题 I have a requirement where I need to group my categorical variables (having more than 5 category values) into 5 groups based on their association with my continuous variable. To achieve this I am using rpart with " annova " method. So for example my categorical variable is type having codes 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 so I want to have 5 groups of this variable. After running the tree inorder to have only 5 groups I need to prune the tree. One way I tried is to use the nsplit from

How to calculate the threshold value for numeric attributes in Quinlan's C4.5 algorithm?

≯℡__Kan透↙ 提交于 2019-12-30 04:57:26
问题 I am trying to find how the C4.5 algorithm determines the threshold value for numeric attributes. I have researched and can not understand, in most places I've found this information: The training samples are first sorted on the values of the attribute Y being considered. There are only a finite number of these values, so let us denote them in sorted order as {v1,v2, …,vm}. Any threshold value lying between vi and vi+1 will have the same effect of dividing the cases into those whose value of

Get decision tree rule/path pattern for every row of predicted dataset for rpart/ctree package in R

故事扮演 提交于 2019-12-28 02:57:27
问题 I have built a decision tree model in R using rpart and ctree . I also have predicted a new dataset using the built model and got predicted probabilities and classes. However, I would like to extract the rule/path, in a single string, for every observation (in predicted dataset) has followed. Storing this data in tabular format, I can explain prediction with reason in a automated manner without opening R. Which means I want to got following. ObsID Probability PredictedClass PathFollowed 1 0

Multiclass Decision Forest vs Random Forest

◇◆丶佛笑我妖孽 提交于 2019-12-25 04:12:24
问题 How does Multiclass Decision Forest differ from Random Forest? What factors do they have in common? It appears there is not a clear answer on the web regarding this matter. 回答1: Random forests or random decision forests is an extension of the decision forests (ensemble of decision trees) combining bagging and random selection of features to construct a collection of decision trees with controlled variance. A very good paper from Microsoft research you may consider to look at. 来源: https:/

get the actual decision tree in pandas

孤者浪人 提交于 2019-12-24 21:32:37
问题 I'm using pandas command tree.DecisionTreeClassifier to build a (binary) classification tree. Something along the lines of: dcrG = tree.DecisionTreeClassifier(criterion='entropy',splitter='best',options_go_here) dcrG.fit(train[features], train['G']) Now that I have succesfully built my decision tree, I would like pandas to print me out the actual decision tree, so something along the lines of if (var1>0.4) if (var4>3.24) if (var2<0.5) return 1 else return 0 else return 1 else if (var3>3.5) if