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

Decision Tree Classifier took 16min to fit

So, for some reasons, It took my laptop to 16min to fit data into DecisionTreeClassifier. It usually take like 1 sec to fit into other type of machine learning model. Anyone can help me with what is happening here? I am not sure what information…
0
votes
2 answers

Decision tree score always return 1

I got 100% score on my test set when trained using decision tree and I think it's a bit strange, given that i set max_depth = 2. And I don't understand that I did wrong. I split my set on train and test sets, but classifier still returns 1. Here is…
Maxim
  • 11
  • 2
0
votes
1 answer

Decision tree regression producing multiple lines

I'm trying to make a single variable regression using decision tree regression. However when I'm plotting the results. Multiple lines show in the plot just like the photo below. I didn't encounter this problem when I used linear…
0
votes
2 answers

how to convert a lista of vectors into a numpy array to train a classifier in python?

I have a pandas data frame that looks like this: corpus tfidf labels 0 dfnkdfnkf asdfhedfh ajdladja [0.0, 0.0, 0.0, 0.01, 0.8] 60 1 dfnkdfnkf asdfhedfh ajdladja [0.0, 0.0, 0.0, 0.01, 0.8] …
Natália Resende
  • 309
  • 1
  • 17
0
votes
1 answer

Error on export_text for decision tree Sklearn

I'm trying to use the function export_text from sklearn.tree (version 1.0.2), but when I'm using the parameter feature_names I get an error, this is what I'm trying # decision_tree is the fitted algorithm text_representation =…
Rodrigo A
  • 657
  • 7
  • 23
0
votes
2 answers

UnicodeDecodeError: 'utf-8' codec can't decode byte

Having trouble loading in this dataset for my Business Intelligence class. I tried a different csv file and that worked. Tried googling some solutions but couldn't figure it out. Any help would be greatly appreciated! # load data col_names =…
0
votes
0 answers

How to fix error in Decision tree prediction in R?

I am unable to fix the code for decision tree prediction. So, my dataset includes 20 variables. Data Set Then, I partitioned my data and created a decision tree Parition of data Decision Tree But while predicting the data, it displays an…
Dolly
  • 1
  • 1
0
votes
1 answer

Decision tree regression code, when run shows only 'random_state = 0' and nothing else

I have taken a house price dataset. I have run the following code: import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns from sklearn.tree import DecisionTreeRegressor from sklearn.model_selection import…
0
votes
1 answer

How Adaboost and decision tree features importances differ?

I have a multiclass classification problem and I extracted features importances based on impurity decrease. I compared a decision tree and AdaBoost classifiers and I ovserved that there is a feature that was ranked on top with the decision tree…
0
votes
0 answers

Extract possible sample combinations from multiple count constraints

I have some input data like this. unique ID Q1 Q2 Q3 1 1 1 2 2 1 1 2 3 1 0 3 4 2 0 1 5 3 1 2 6 4 1 3 And my target is to extract some data which satisfy the following conditions: total count: 4 Q1=1 count: 2 Q1=2 count: 1 Q2=1…
cindy50633
  • 144
  • 2
  • 11
0
votes
0 answers

How to render a full image of decision tree using Matplotlib

I am working on a program to create a decision tree. The following method below should save an image of the tree: def save_image(clf_, filename, feat_names, class_names, show=True): """Plot the tree and save to file.""" plt.figure(dpi=200) …
Evan Gertis
  • 1,796
  • 2
  • 25
  • 59
0
votes
1 answer

How to plot the DecisionTree out of a SkLearn Pipeline?

So I am working on a decision tree within a SkLearn Pipeline. The model works fine. However, I am not able to plot the decision tree. I am not sure which object to use by calling the .plot method. Here is my code to create the Decision Tree…
0
votes
1 answer

Having trouble calculating mean squared error in sklearn python

I am trying to fit a decision tree regressor to a dataset, and it is working but when I test it out by calculating mean squared error. I get an error that looks like this: msee = mse(x_test, y_test) ValueError …
Jensen_ray
  • 81
  • 2
  • 10
0
votes
0 answers

How can I compute the accuracy of the classification tree from rpart when xval is not 0?

I want to compare the performance of the model with kNN and Naïve Bayes. But the problem is that I can't interpret the result in the form of accuracy. In this case, I did not set any training and test set but set xval = 10 in the process. So, how…
0
votes
1 answer

Scikit Learn DecisionTreeRegressor algorithm not consistent

I am currently using decision trees (using Scikit Learn DecisionTreeRegressor) to fit Regression tree. The problem I'm facing is that using the algorithm with same data as 6 months ago there is a slight change in output (ie. the optimal split…