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
0
votes
1 answer

Is it possible to get dict {class: proba} from Decision Tree Classifier predict_proba()?

My model have more than 1k classes, and the method returns an array with probabilities, most of which are 0. I want to get top 3 predictions with their probabilities. How can i implement this? I expect to get something like this: [{class: proba},…
0
votes
1 answer

Objects of type prcomp not supported by autoplot

I have a data frame of multiple columns. I want to carry out PCA and classification with decision trees to check if information on il.count.ratio to une.count.ratio can actually help to differentiate the two professions. Profession il.count.ratio…
Fella
  • 21
  • 5
0
votes
1 answer

Path error when visualising decision tree classification PySpark using dtreeviz

I am trying to visualise my decision tree classification using the code in GitHub in the following link https://github.com/parrt/dtreeviz/blob/master/notebooks/dtreeviz_spark_visualisations.ipynb when I am implementing the code: df =…
Roaa
  • 1
  • 3
0
votes
1 answer

model.features_names_in not working for decision trees in Anaconda Jupyter Notebook

is there any way I can get the feature names of the decision tree model as defined below using sklearn or any other packages in the Anaconda Jupyter Notebook? I'm trying to work on this issue for a long time now, but have not been able to search for…
Harsh780
  • 13
  • 5
0
votes
3 answers

Import Error: cannot import name 'tree' from 'sklearn.tree'

I am on my second day of re-taking Python for the gazillionth time! I am doing a tutorial on ML in Python, using the following code: import sklearn.tree import pandas as pd from sklearn.tree import DecisionTreeClassifier from sklearn.tree import…
rgd90
  • 13
  • 2
0
votes
1 answer

Rpart / Rpart.plot - what do decimals mean in node?

I understand the numbers followed by a "%" But I am having trouble interpreting the numbers in decimals. This is a type=1 plot. Choice is Buy or Browse. Fake data browsing an electronics store website. Phase = first page visited, second page…
M_S_Pen
  • 1
  • 1
0
votes
0 answers

Is duplication okay in random forest modelling?

I am using random forest modelling for a project. The tool used is SAS Eguide. My data is 12 months history with a moving payment history. Below table summarizes my…
0
votes
1 answer

How to export_tree for GradientBoostingClassifier?

This code works for DecisionTreeClassifier. r = export_text(tree2, feature_names=fn) print(r) And for RandomForestClassifier from sklearn.tree import export_text print(export_text(tree3.estimators_[0], spacing=3, decimals=3, …
0
votes
1 answer

Accuracy score in Decision Tree

Part 1 decision_tree.fit(X_train, y_train) Y_val = decision_tree.predict(X_val) acc_decision_tree_train = round(decision_tree.score(X_train, y_train) * 100, 2) acc_decision_tree_train Part 2 acc_decision_tree_val = round(decision_tree.score(X_val,…
0
votes
1 answer

How to add custom tree to custom Keras layer?

I am trying to bring together the following tutorials: Creating decision tree by hand Custom layers via subclassing Composing Decision Forest and Neural Network models The goal is to 1. Create a custom tree, 2. Embed it into a custom layer and 3.…
Konstantin
  • 396
  • 3
  • 19
0
votes
0 answers

Plot a path of the decision tree in python

The answer of this question can highlight the path of a decision tree, but is there any way to only plot a single path of a decision tree in python? My decision tree is built by tree.DecisionTreeClassifier() in scikit-learn and visualized by…
0
votes
1 answer

visualizing regression tree model with continuous numerical target class?

I am practicing with this life expectancy dataset from Kaggle (https://www.kaggle.com/datasets/kumarajarshi/life-expectancy-who?select=Life+Expectancy+Data.csv) and I want to train and visualize a classification and regression tree model. however, I…
user18862660
0
votes
1 answer

Interaction between sample_weight and min_samples_split in decision tree

In sklearn.ensemble.RandomForestClassifier, if we define both sample_weight and min_samples_split, does the sample weight impact the min_samples_split. For example, if min_sample_split = 20 and the weight of data points in samples are all 2, then 10…
Hossein
  • 106
  • 8
0
votes
1 answer

How to tune mtry and number of trees simultaneously for a Random Forest Regression?

I am trying to tune parameters for a Random Forest using caret and method ranger. I have seen codes for tuning mtry using tuneGrid. And then using the resulted mtry to run loops and tune the number of trees (num.tree). However, I would like to know…
0
votes
1 answer

Decision tree split implementation

I am doing this as a part of my university assignment, but I can't find any resources online on how to correctly implement this. I have read tons materials on metrics that define optimal set split (like Entropy, Gini and others), so I understand how…