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

C++ Decision Tree Implementation Question: Think In Code

I've been coding for a few years but I still haven't gotten the hang of pseudo-coding or actually thinking things out in code yet. Due to this problem, I'm having trouble figuring out exactly what to do in creating a learning Decision Tree. Here…
CodingImagination
  • 135
  • 1
  • 2
  • 11
11
votes
3 answers

Prune unnecessary leaves in sklearn DecisionTreeClassifier

I use sklearn.tree.DecisionTreeClassifier to build a decision tree. With the optimal parameter settings, I get a tree that has unnecessary leaves (see example picture below - I do not need probabilities, so the leaf nodes marked with red are a…
Thomas
  • 4,696
  • 5
  • 36
  • 71
11
votes
1 answer

Changing colors for decision tree plot created using export graphviz

I am using scikit's regression tree function and graphviz to generate the wonderful, easy to interpret visuals of some decision trees: dot_data = tree.export_graphviz(Run.reg, out_file=None, feature_names=Xvar, …
June Skeeter
  • 1,142
  • 2
  • 13
  • 27
11
votes
1 answer

Why is the runtime to construct a decision tree mnlog(n)?

When m is the amount of features and n is the amount of samples, the python scikit-learn site (http://scikit-learn.org/stable/modules/tree.html) states that the runtime to construct a binary decision tree is mnlog(n). I understand that the log(n)…
11
votes
2 answers

Use one attribute only once in scikit-learn decision tree in python

I am using scikit-learn to create a decision tree, and its working like a charm. I would like to achieve one more thing: to make the tree to split on an attribute only once. The reason behind this is because of my very strange dataset. I use a noisy…
Gábor Erdős
  • 3,599
  • 4
  • 24
  • 56
11
votes
3 answers

How do I visualise / plot a decision tree in Apache Spark (PySpark 1.4.1)?

I am using Apache Spark Mllib 1.4.1 (PySpark, the python implementation of Spark) to generate a decision tree based on LabeledPoint data I have. The tree generates correctly and I can print it to the terminal (extract the rules as this user calls it…
PyRsquared
  • 6,970
  • 11
  • 50
  • 86
11
votes
3 answers

Python, PyDot and DecisionTree

I'm trying to visualize my DecisionTree, but getting the error The code is: X = [i[1:] for i in dataset]#attribute y = [i[0] for i in dataset] clf = tree.DecisionTreeClassifier() dot_data = StringIO() tree.export_graphviz(clf.fit(train_X, train_y),…
Polly
  • 1,057
  • 5
  • 14
  • 23
11
votes
2 answers

How to handle categorical variables in sklearn GradientBoostingClassifier?

I am attempting to train models with GradientBoostingClassifier using categorical variables. The following is a primitive code sample, just for trying to input categorical variables into GradientBoostingClassifier. from sklearn import datasets from…
11
votes
6 answers

C5.0 decision tree - c50 code called exit with value 1

I am getting the following error c50 code called exit with value 1 I am doing this on the titanic data available from Kaggle # Importing datasets train <- read.csv("train.csv", sep=",") # this is the structure str(train) Output :- …
zephyr
  • 1,775
  • 6
  • 20
  • 31
11
votes
1 answer

Decision Tree in Matlab

I saw the help in Matlab, but they have provided an example without explaining how to use the parameters in the 'classregtree' function. Any help to explain the use of 'classregtree' with its parameters will be appreciated.
user238469
11
votes
2 answers

Best learning algorithm to make a decision tree in java?

I have a datasets with information like age, city, age of children, ... and a result (confirm, accept). To help modelisation of "workflow", I want to create automatically a decision tree based on previous datasets. I have take a look at…
X-Blaster
  • 1,751
  • 3
  • 15
  • 32
11
votes
2 answers

pydot: is it possible to plot two different nodes with the same string in them?

I'm using pydot in order to draw graphs in python. I'd like to represent a decision tree, say something like (a1,a2,a3 are attributes and two classes are 0 and 1: a1>3 / \ a2>10 a3>-7 / \ / \ 1 0 1 0 However,…
ScienceFriction
  • 1,538
  • 2
  • 18
  • 29
11
votes
3 answers

PHP function to increment variable by 1 each time

I have started writing a PHP script for a game about creatures, there are 4 yes/no questions and what I am trying to do is write a function that will display 2 buttons that say yes and no and give then different names each time I run the function,…
Harry12345
  • 1,144
  • 6
  • 20
  • 47
10
votes
2 answers

How to implement a decision tree in javascript. Looking for a better solution than my ugly ones

I'm looking for a better way to implement a decision tree in javascript. Being very new to programming I have a very limited number of tools in my toolbox. The only ways I know to do this are: .with a huge ugly hard to maintain and follow if else…
Dale
  • 1,289
  • 3
  • 16
  • 36
10
votes
4 answers

Value Error X has 24 features, but DecisionTreeClassifier is expecting 19 features as input

I'm trying to reproduce this GitHub project on my machine, on Topological Data Analysis (TDA). My steps: get best parameters from a cross-validation output load my dataset feature selection extract topological features from the dataset for…
8-Bit Borges
  • 9,643
  • 29
  • 101
  • 198