2,512 questions
6
votes
2
answers
103
views
Reproduce a particular tree from the random forest using DecisionTreeRegressor
I am trying to replicate a specific decision tree trained by a RandomForestRegressor class, using DecisionTreeRegressor.
However, I cannot get the exact results, even with using the exact same ...
1
vote
0
answers
88
views
Why is DecisionTree using same feature and same condition twice
When trying to fit scikit-learn DecisionTreeClassifier on my data, I am observing some weird behavior.
x[54] (a boolan feature) is used to break the 19 samples into 2 and 17 on top left node. Then ...
0
votes
0
answers
67
views
Get rule interpretations in h2o rulefit model
Following the example for h2o rulefit model from the documentation (https://docs.h2o.ai/h2o/latest-stable/h2o-docs/data-science/rulefit.html), I checked the variable importance of the rules or linear ...
0
votes
0
answers
47
views
Define a custom tree splitter from sklearn
I'm trying to define a custom splitter using sklearn Classification Trees classes, but I'm getting no results so far. I got no errors but the tree is not developed. How to achieve this?
My strategy is ...
1
vote
1
answer
49
views
Plotting one Decision Tree of a Random Forest in sklearn
I have come around a strange thing when plotting a decision tree in sklearn.
I just wanted to compare a Random Forest model consisting of one estimator using bootstrapping and one without ...
0
votes
0
answers
38
views
Draw a decision tree while hiding the values of the "value" row
I want to simplify the decision tree output and hide the values in the "value" field.Below is the code I am using
enter image description here
fig, ax = plt.subplots(figsize=(10, 10))
...
0
votes
1
answer
42
views
sklearn plot_tree function does not show the class when the tree has only one node
I use the following code to plot a decisions trees:
plt.figure(figsize=(12, 12))
plot_tree(estimator,
feature_names=feature_names,
label= 'all',
...
0
votes
0
answers
55
views
Data structure for summing and taking the max of decision trees
I have a tree structure that I'm using to represent a set of decisions and the resulting payout:
Here there are two choices to be made: 0 can be either a, b or c, and 1 can be either d or e. The ...
2
votes
1
answer
138
views
Is set.seed() needed when building a single decision tree in R?
I am learning how to build a single decision tree and random forests in R. I understand that set.seed() is needed before building a random forest to ensure reproducibility of the results, e.g. if ...
1
vote
1
answer
52
views
How to apply the exported sklearn trained tree to the test data
from sklearn.tree import DecisionTreeRegressor, export_text
cols_X = ['f1', 'f2']
df_train = pd.DataFrame([[1, 3, 4], [2, 5, 1], [7, 8, 7]], columns=['f1', 'f2', 'label'])
df_test = pd.DataFrame([[2, ...
-3
votes
2
answers
71
views
ValueError: could not convert string to float: '?' while working with MSE
I am using the auto-mpg dataset . I am giving the link of the dataset below:
https://www.kaggle.com/datasets/uciml/autompg-dataset
I am giving the code below:
df = pd.read_csv('data/auto-mpg.csv')
df....
0
votes
1
answer
82
views
How to manually adjust a decision tree obtained from rpart, including surrogate splits?
I built a decision tree with surrogate splits using rpart. Now, after inspection of the tree by a subject matter expert, the tree needs some small manual adjustment (addition of an extra branch).
...
0
votes
0
answers
74
views
I am trying to replicate a decision tree from SPSS in python using DecisionTreeClassifier
I am trying to replicate a decision tree from SPSS in python using DecisionTreeClassifier. I am unable to do the following.
Unable to use a feature to do the first force split.
If I use the same ...
0
votes
1
answer
73
views
KeyError in Decision Tree during prediction
I want to create predict and predict_proba methods in my DecisionTreeClassifier implementation, but it gives the error
Traceback (most recent call last):
File "c:\Users\Nijat\project.py", ...
1
vote
0
answers
243
views
Apply large number of decision tree rules to SQL data
I want to apply rules that I've created from modelling on data using a decision tree to unseen data. I've parsed the rules to get a CASE WHEN statement like so:
CASE
WHEN variable_1 = "Value1&...
-1
votes
1
answer
95
views
Decision Tree Regressor Output
I have a very simple dataset of employee age and years of experience as features and income as label. The ask is to predict the income level using various regressors and I am using 4: Decision Trees (...
1
vote
2
answers
161
views
Random Forest / Decision Tree Output Probability Design: Using Positive Output Leaf Samples / Total Output Leaf Samples
I am designing a binary classifier random forest model using python and scikitlearn, in which I would like to retrieve the probability of my test set being one of the two labels. To my understanding, ...
1
vote
1
answer
1k
views
Is there a difference in the underlying sklearn 'entropy' and 'log_loss' criteria for decision tree classifiers?
I'm implementing an decision tree classifier using sklearn and testing out different criteria, but I can't seem to find what the difference is between the 'entropy' and 'log_loss' criteria. The ...
0
votes
0
answers
47
views
Partykit predict function throws warning when predicting with new data
Im trying to predict new data with a ctree object. I get this warning message when I run the function:
b1b2_party <- ctree(factor(final_category_bin) ~ ., data = train, control = ctree_control(...
-1
votes
1
answer
50
views
Line of code not compiling in jupyter notebook
I'm trying to build a second dataframe in Jupyter Notebook to train a stronger model.
This is the line of code:
dtc2 = DecisionTreeClassifier(criterion = 'entropy', ccp_alpha=0.04)
I'm getting a type ...
0
votes
1
answer
104
views
Decision Tree prediction for the fail reason
In my experiment, I used Decision Trees to predict whether participants will pass or fail, and I will provide feedback to them based on the reason for their failure. The Decision Tree includes three ...
0
votes
1
answer
136
views
Creating Tensorflow decision forests from individual trees
Is possible to build a decision forest with TensorFlow from many individual decision trees? Also, remove and add individual trees that are in the decision forest based on some performance criteria? ...
-4
votes
1
answer
53
views
How does persisting the model increase accuracy?
import pandas as pd
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score, f1_score
whitewine_data = pd....
0
votes
1
answer
113
views
AttributeError: 'RandomForestRegressor' object has no attribute 'tree_'. How do i resolve?
I am trying to use the random forest model to predict social media ads effects based on age and estimated salary, this is my code but i keep getting Attribute error prompting up.
from sklearn.tree ...
0
votes
1
answer
140
views
Error when importing DecisionTreeClassifier from sklearn
When I try to import a DecisionTreeClassifier from sklearn.tree I receive the following attribute error: AttributeError: module 'numpy' has no attribute 'float'
My code is:
import sklearn
print(...