Questions tagged [decision-tree]

A decision tree is a decision support tool that uses a tree-like graph or model of decisions and their possible consequences, including chance event outcomes, resource costs, and utility. It is one way to display an algorithm.

Decision Tree could be just a graphical tool or the learning algorithm in a post.

2545 questions
29
votes
2 answers

scikit learn - feature importance calculation in decision trees

I'm trying to understand how feature importance is calculated for decision trees in sci-kit learn. This question has been asked before, but I am unable to reproduce the results the algorithm is providing. For example: from StringIO import…
28
votes
2 answers

How to plot a large ctree() to avoid overlapping nodes

When I plotted the decision tree result from ctree() from party package, the font was too big and the box was also too big. They are overlapping other nodes. Is there a way to customize the output from plot() so that the box and the font would be…
JPC
  • 5,063
  • 20
  • 71
  • 100
26
votes
2 answers

Using sklearn, how do I find depth of a decision tree?

I am training a decision tree with sklearn. When I use: dt_clf = tree.DecisionTreeClassifier() the max_depth parameter defaults to None. According to the documentation, if max_depth is None, then nodes are expanded until all leaves are pure or…
Mel
  • 6,214
  • 10
  • 54
  • 71
24
votes
4 answers

What does the value of 'leaf' in the following xgboost model tree diagram means?

I am guessing that it is conditional probability given that the above (tree branch) condition exists. However, I am not clear on it. If you want to read more about the data used or how do we get this diagram then go to :…
dsl1990
  • 1,157
  • 5
  • 13
  • 25
24
votes
1 answer

cross validation + decision trees in sklearn

Attempting to create a decision tree with cross validation using sklearn and panads. My question is in the code below, the cross validation splits the data, which i then use for both training and testing. I will be attempting to find the best depth…
razeal113
  • 451
  • 1
  • 4
  • 13
20
votes
1 answer

OpenCV - Random Forest Example

Does anyone have some example using Random Forests with the 2.3.1 API Mat and not the cvMat? Basically I have a Matrix Mat data that consists of 1000 rows with 16x16x3 elements and a Matrix Mat responses a 1000x1 matrix that holds which class each…
Poul K. Sørensen
  • 16,950
  • 21
  • 126
  • 283
20
votes
3 answers

How to extract sklearn decision tree rules to pandas boolean conditions?

There are so many posts like this about how to extract sklearn decision tree rules but I could not find any about using pandas. Take this data and model for example, as below # Create Decision Tree classifer object clf =…
Jack
  • 1,724
  • 4
  • 18
  • 33
20
votes
1 answer

Why is Random Forest with a single tree much better than a Decision Tree classifier?

I apply the decision tree classifier and the random forest classifier to my data with the following code: def decision_tree(train_X, train_Y, test_X, test_Y): clf = tree.DecisionTreeClassifier() clf.fit(train_X, train_Y) return…
19
votes
2 answers

How to implement decision tree with c# (visual studio 2008) - Help

I have a decision tree that i need to turn to a code in C# The simple way of doing it is using if-else statements but in this solution i will need to create 4-5 nested conditions. I am looking for a better way to do it and so far i read a little bit…
Chen
  • 191
  • 1
  • 1
  • 3
19
votes
6 answers

How to implement decision matrix in c#

I need to make a decision based on a rather large set of 8 co-dependent conditions. | A | B | C | D | E | F | G | H -----------+---+---+---+---+---+---+---+--- Decision01 | 0 | 1 | - | 1 | 0 | 1 | - | 1 Decision02 | 1 | 0 | - | 0 | 0 | -…
Aether McLoud
  • 732
  • 1
  • 7
  • 20
18
votes
7 answers

How to explore a decision tree built using scikit learn

I am building a decision tree using clf = tree.DecisionTreeClassifier() clf = clf.fit(X_train, Y_train) This all works fine. However, how do I then explore the decision tree? For example, how do I find which entries from X_train appear in a…
Simd
  • 19,447
  • 42
  • 136
  • 271
17
votes
2 answers

How to read the classifier confusion matrix in WEKA

Sorry, I am new to WEKA and just learning. In my decision tree (J48) classifier output, there is a confusion Matrix: a b <----- classified as 130 8 a = functional 15 150 b = non-functional How do I read this matrix? What's the…
JakeSays
  • 2,048
  • 8
  • 29
  • 43
16
votes
3 answers

how to calculate accuracy from decision trees?

Hi, I am taking a course on Coursera and came into this question. My answer is 1-(4048+3456)/8124=0.076. However, the answer is 0.067. Anybody can help me to solve this? Thank you!!
Chao Li
  • 169
  • 1
  • 1
  • 3
16
votes
1 answer

How to explain feature importance after one-hot encode used for decision tree

I know decision tree has feature_importance attribute calculated by Gini and it could be used to check which features are more important. However, for application in scikit-learn or Spark, it only accepts numeric attribute, so I have to transfer…
linpingta
  • 2,324
  • 2
  • 18
  • 36
15
votes
5 answers

Visualizing Weka classification tree

I am using few data sets available online and trying to visualize tree. However, it does not let me visualize tree option at all. Could anyone please guide me how to get the tree diagram in weka by using data sets available online?
Ramakrishna