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
7
votes
3 answers

GridSearchCV scoring parameter: using scoring='f1' or scoring=None (by default uses accuracy) gives the same result

I'm using an example extracted from the book "Mastering Machine Learning with scikit learn". It uses a decision tree to predict whether each of the images on a web page is an advertisement or article content. Images that are classified as being…
7
votes
3 answers

in R: Error in is.data.frame(data) : object '' not found, C5.0 plot

This question is similar to some other questions on Stackoverflow (here, here and here), but different enough so that I cannot extrapolate those answers to my case. I have a function in which I fit a C5.0 model and than try to plot the…
user989762
  • 1,686
  • 3
  • 16
  • 20
7
votes
2 answers

Finding a corresponding leaf node for each data point in a decision tree (scikit-learn)

I'm using decision tree classifier from the scikit-learn package in python 3.4, and I want to get the corresponding leaf node id for each of my input data point. For example, my input might look like this: array([[ 5.1, 3.5, 1.4, 0.2], […
neobot
  • 1,210
  • 1
  • 14
  • 19
7
votes
2 answers

Force the left to right order of nodes in graphviz?

I want to draw a decision tree chart using graphviz. The graph I want to draw looks like this: I am using the following dot language: graph a { A [shape=box; label="A"] B [shape=box; label="B"] al [shape=none; label="0"] bl [shape=none;…
Letholdrus
  • 1,261
  • 3
  • 20
  • 36
7
votes
2 answers

What is the difference between rel error and x error in a rpart decision tree?

I have a purely categorical dataframe from the UCI machine learning database https://archive.ics.uci.edu/ml/datasets/Diabetes+130-US+hospitals+for+years+1999-2008 I am using rpart to form a decision tree based on a new category on whether patients…
user1745691
  • 305
  • 2
  • 5
  • 12
7
votes
4 answers

Classification tree in sklearn giving inconsistent answers

I am using a classification tree from sklearn and when I have the the model train twice using the same data, and predict with the same test data, I am getting different results. I tried reproducing on a smaller iris data set and it worked as…
sedavidw
  • 11,116
  • 13
  • 61
  • 95
7
votes
3 answers

can "splitting attribute" appear many times in decision tree?

Just want to clarify one thing: the same attribute can appear in decision tree for many times as long as they are in different "branches" right?
yvetterowe
  • 1,239
  • 7
  • 20
  • 34
7
votes
3 answers

does scikit-lean decision tree support unordered ('enum') multiclass features?

From the documentation, it appears that DecisionTreeClassifier supports multiclass features DecisionTreeClassifier is capable of both binary (where the labels are [-1, 1]) classification and multiclass (where the labels are [0, ..., K-1])…
Ophir Yoktan
  • 8,149
  • 7
  • 58
  • 106
7
votes
1 answer

python and validating business rules based on a decision tree

Say you have a set of determistic business rules in an admin system that you want to check. The rules can be based on numeric, boolean, categorical, etc. values, e.g.: if product in ['x','y','z']: if age > 30: if amount < 100000: …
luck
  • 89
  • 3
6
votes
1 answer

Visualize decision tree with not only training set tag distribution, but also test set tag distribution

We can visualize decision tree with training set distribution, for example from matplotlib import pyplot as plt from sklearn import datasets from sklearn.tree import DecisionTreeClassifier from sklearn import tree # Prepare the data data, can do…
Jiadong Chen
  • 115
  • 8
6
votes
1 answer

R: Extracting Rules from a Decision Tree

I am working with the R programming language. Recently, I read about a new decision tree algorithm called "Reinforcement Learning Trees" (RLT) which supposedly has the potential to fit "better" decision trees to a dataset. The documentation for…
stats_noob
  • 5,401
  • 4
  • 27
  • 83
6
votes
2 answers

What is the meaning of "value" in a node in sklearn decisiontree plot_tree

I plotted my sklearn decision tree using the plot_tree function. The nodes have the following structure: But I don't understand what does the value = [2417, 1059] mean. In other nodes there are other values. Thanks for explaining.
LBoss
  • 496
  • 6
  • 15
6
votes
1 answer

Custom Criterion for DecisionTreeRegressor in sklearn

I want to use a DecisionTreeRegressor for multi-output regression, but I want to use a different "importance" weight for each output (e.g. predicting y1 accurately is twice as important as predicting y2). Is there a way of including these weights…
6
votes
2 answers

caret rpart decision tree plotting result

I am training a decision tree model based on the heart disease data from Kaggle. Since I am also building other models using 10-fold CV, I am trying to use caret package with rpart method to build the tree. However, the plot result is weird as…
Rui Tongyu
  • 79
  • 4
6
votes
1 answer

How to display the path of a Decision Tree for test samples?

I'm using DecisionTreeClassifier from scikit-learn to classify some multiclass data. I found many posts describing how to display the decision tree path, like here, here, and here. However, all of them describe how to display the tree for the…
Alaa M.
  • 4,961
  • 10
  • 54
  • 95