decision-tree

How to change the threshold on decision tree classifier model?

How to change the threshold on decision tree classifier model? Question: Is it possible to change the threshold of a decisiontreeclassifier? I’m studying the precision/recall trade-off and want to change the threshold to favor recall. I’m studying the hand’s on ML, but there it uses the SGDClassifier, at some point it uses the cross_val_predict() with …

Total answers: 1

Duplicated feature and criteria from sklearn RandomForest when examining the decision path

Duplicated feature and criteria from sklearn RandomForest when examining the decision path Question: I’m getting duplicated feature and threshold (CO2) when examining the decision tree from a random forest model. The code to visualize the tree is the following: estimator = model.estimators_[10] from sklearn.tree import export_graphviz # Export as dot file export_graphviz(estimator, out_file=’tree.dot’, feature_names = …

Total answers: 1

How does scikit-learn DecisionTreeClassifier handle duplicate values when determining potential split points for a continuous predictor variable?

How does scikit-learn DecisionTreeClassifier handle duplicate values when determining potential split points for a continuous predictor variable? Question: Suppose I have a continuous predictor variable with values of 10, 20, 20, 30. I understand that the set of potential split thresholds would include {15, 25}, as these are the means of 10 & 20 and …

Total answers: 1

Pyinstaller created exe file cannot load Decision Tree model using joblib

Pyinstaller created exe file cannot load Decision Tree model using joblib Question: I created an exe file of my large python script using the following command – pyinstaller gui_final.py –onefile –hidden-import=sklearn –hidden-import=ipaddress –hidden-import=PIL –hidden-import=pickle –hidden-import=shutil –hidden-import=joblib The exe file works fine until I load my decision tree model file (dtree.joblib) using JOBLIB. clf = joblib.load("dtree.joblib") …

Total answers: 1

increase the size of nodes in decision tree

increase the size of nodes in decision tree Question: I am using decision tree classifier and want to plot the tree using matplotlib I am using this but nodes are small and not clear: from sklearn import tree import matplotlib.pyplot as plt plt.figure(figsize=(15,15)) tree.plot_tree(model_dt_smote,filled=True) Asked By: Nitish Santpur || Source Answers: You can pass axe …

Total answers: 1

AttributeError: type object 'sklearn.tree._criterion.array' has no attribute '__reduce_cython__'

AttributeError: type object 'sklearn.tree._criterion.array' has no attribute '__reduce_cython__' Question: I want to import from sklearn.tree import DecisionTreeRegressor in jupyter. but when I run just the line contains above import, I got this error. <ipython-input-16-28b3e81cd98d> in <module> —-> 1 from sklearn.tree import DecisionTreeRegressor ~/.local/lib/python3.6/site-packages/sklearn/tree/__init__.py in <module> 4 “”” 5 —-> 6 from ._classes import BaseDecisionTree 7 …

Total answers: 1

Drawing Decision tree with python

Drawing Decision tree with python Question: I working on a draw decision tree with python, tree.plot_tree(clf.fit(X_train, y_train)) plt.suptitle(“Decision surface of a decision tree using paired features”) plt.show() but when I run this code, the tree shows up like this Decision Tree Is there any possible way to make the tree normal? Asked By: jkim37 || …

Total answers: 1

scikit learn – feature importance calculation in decision trees

scikit learn – feature importance calculation in decision trees Question: I’m trying to understand how feature importance is calculated for decision trees in sci-kit learn. This question has been asked before, but I am unable to reproduce the results the algorithm is providing. For example: from StringIO import StringIO from sklearn.datasets import load_iris from sklearn.tree …

Total answers: 2

decision tree repeating class names

decision tree repeating class names Question: I have a very simple sample of data/labels, the problem I’m having is that the decision tree generated (pdf) is repeating the class name: from sklearn import tree from sklearn.externals.six import StringIO import pydotplus features_names = [‘weight’, ‘texture’] features = [[140, 1], [130, 1], [150, 0], [110, 0]] labels …

Total answers: 2

confused about random_state in decision tree of scikit learn

confused about random_state in decision tree of scikit learn Question: Confused about random_state parameter, not sure why decision tree training needs some randomness. My thoughts is it related to random forest? is it related to split training testing data set? If so, why not use training testing split method directly (http://scikit-learn.org/stable/modules/generated/sklearn.cross_validation.train_test_split.html)? http://scikit-learn.org/stable/modules/generated/sklearn.tree.DecisionTreeClassifier.html from sklearn.datasets import …

Total answers: 5