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
15
votes
2 answers

Plot Confusion Matrix for multilabel Classifcation Python

I'm looking for someone who can help me to plot my Confusion Matrix. I need this for a term paper at the university. However I have very little experience in programming. In the pictures you can see the classification report and the structure of my…
15
votes
3 answers

Feature importances - Bagging, scikit-learn

For a project I am comparing a number of decision trees, using the regression algorithms (Random Forest, Extra Trees, Adaboost and Bagging) of scikit-learn. To compare and interpret them I use the feature importance , though for the bagging decision…
15
votes
3 answers

What is a good Python library for decision trees?

Unless I'm missing something, the usual suspects don't have this....
Ash
  • 895
  • 2
  • 9
  • 18
14
votes
4 answers

displaying scikit decision tree figure in jupyter notebook

I am currently creating a machine learning jupyter notebook as a small project and wanted to display my decision trees. However, all options I can find are to export the graphics and then load a picture, which is rather complicated. Therefore, I…
14
votes
1 answer

How to access weighting of indiviual decision trees in xgboost?

I'm using xgboost for ranking with param = {'objective':'rank:pairwise', 'booster':'gbtree'} As I understand gradient boosting works by calculating the weighted sum of the learned decision trees. How can I access the weights that are assigned to…
саша
  • 521
  • 5
  • 20
14
votes
1 answer

How to prune a tree in R?

I'm doing a classification using rpart in R. The tree model is trained by: > tree <- rpart(activity ~ . , data=trainData) > pData1 <- predict(tree, testData, type="class") The accuracy for this tree model is: >…
zfz
  • 1,597
  • 1
  • 22
  • 45
13
votes
1 answer

Display more attributes in the decision tree

I am currently viewing the decision tree using the following code. Is there a way that we can export some calculated fields as output too? For example, is it possible to display the sum of an input attribute at each node, i.e. sum of feature 1 from…
Praveen Gupta Sanka
  • 609
  • 1
  • 8
  • 25
13
votes
1 answer

Can sklearn DecisionTreeClassifier truly work with categorical data?

While working with the DecisionTreeClassifier I visualized it using graphviz, and I have to say, to my astonishment, it seems it takes categorical data and uses it as continuous data. All my features are categorical and for example you can see the…
13
votes
3 answers

How to balance classification using DecisionTreeClassifier?

I have a data set where the classes are unbalanced. The classes are either 0, 1 or 2. How can I calculate the prediction error for each class and then re-balance weights accordingly in scikit-learn?
RoyaumeIX
  • 1,947
  • 4
  • 13
  • 37
13
votes
3 answers

Data Driven Rules Engine - Drools

I have been evaluating Drools as a Rules Engine for use in our Business Web Application. My use case is a Order Management Application. And the rules are of following kind: - If User Type is "SPECIAL" give an extra 5% discount. - If User has made…
Jasper
  • 8,440
  • 31
  • 92
  • 133
12
votes
3 answers

XGBoost - n_estimators = 1 equal to single-tree classifier?

I have some training pipeline that heavily uses XGBoost instead of scikit-learn, only because of the way XGBoost cleanly handles null values. However, I'm tasked with introducing non-technical folks to machine learning, and thought it'd be good to…
blacksite
  • 12,086
  • 10
  • 64
  • 109
12
votes
1 answer

result of rpart is a root, but data shows Information Gain

I have a dataset with an event rate of less than 3% (i.e. there are about 700 records with class 1 and 27000 records with class 0). ID V1 V2 V3 V5 V6 Target SDataID3 161 ONE 1 FOUR 0 0 SDataID4 11 TWO 2 …
12
votes
2 answers

What is the output of clf.tree_.feature?

I observed that scikit-learn clf.tree_.feature occasional return negative values. For example -2. As far as I understand clf.tree_.feature is supposed to return sequential order of the features. In case we have array of feature names…
user1700890
  • 7,144
  • 18
  • 87
  • 183
12
votes
3 answers

Get feature and class names into decision tree using export graphviz

Good Afternoon, I am working on a decision tree classifier and am having trouble visualizing it. I can output the decision tree, however I cannot get my feature or class names/labels into it. My data is in a pandas dataframe format which I then move…
sokeefe1014
  • 227
  • 1
  • 3
  • 9
12
votes
1 answer

Library to generate a decision tree

Is there a C# Library to generate a decision tree from a datatable and then use it to predict missing data? I did some researches but did not find any C# library that can generate a decision tree from a set of data. Any help is greatly…
Y2theZ
  • 10,162
  • 38
  • 131
  • 200