decision-tree

Error when using Decision Trees in OpenCV 3.0.0-rc1

扶醉桌前 提交于 2021-02-19 06:01:15
问题 I am doing some machine learning in OpenCV and i'm using Decision Trees . I am currently using OpenCV 3.0.0-rc1 . Whenever i attempt to train Decision Trees with my training data and labels, i get either terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc or Segmentation fault Depending on what i put into setMaxDepth(); if the number is larger than 22, it's bad_alloc, else it's seg fault. Here's my source code: //import data Mat trainData=imread("/home

Data Prediction using Decision Tree of rpart

妖精的绣舞 提交于 2021-02-18 22:28:47
问题 I am using R to classify a data-frame called 'd' containing data structured like below: The data has 576666 rows and the column "classLabel" has a factor of 3 levels: ONE, TWO, THREE. I am making a decision tree using rpart: fitTree = rpart(d$classLabel ~ d$tripduration + d$from_station_id + d$gender + d$birthday) And I want to predict the values for the "classLabel" for newdata : newdata = data.frame( tripduration=c(345,244,543,311), from_station_id=c(60,28,100,56), gender=c("Male","Female",

Extracting Information from the Decision Rules in rpart package

社会主义新天地 提交于 2021-02-16 20:58:13
问题 I need to extract information from the rules in decision tree. I am using rpart package in R. I am using demo data in the package to explain my requirements: data(stagec) fit<- rpart(formula = pgstat ~ age + eet + g2 + grade + gleason + ploidy, data = stagec, method = "class", control=rpart.control(cp=0.05)) fit printing fit shows n= 146 node), split, n, loss, yval, (yprob) * denotes terminal node 1) root 146 54 0 (0.6301370 0.3698630) 2) grade< 2.5 61 9 0 (0.8524590 0.1475410) * 3) grade>=2

Extracting Information from the Decision Rules in rpart package

送分小仙女□ 提交于 2021-02-16 20:58:06
问题 I need to extract information from the rules in decision tree. I am using rpart package in R. I am using demo data in the package to explain my requirements: data(stagec) fit<- rpart(formula = pgstat ~ age + eet + g2 + grade + gleason + ploidy, data = stagec, method = "class", control=rpart.control(cp=0.05)) fit printing fit shows n= 146 node), split, n, loss, yval, (yprob) * denotes terminal node 1) root 146 54 0 (0.6301370 0.3698630) 2) grade< 2.5 61 9 0 (0.8524590 0.1475410) * 3) grade>=2

Decision Tree Sklearn -Depth Of tree and accuracy

天大地大妈咪最大 提交于 2021-02-16 09:22:12
问题 I am applying Decision Tree to a data set, using sklearn In Sklearn there is a parameter to select the depth of the tree - dtree = DecisionTreeClassifier(max_depth=10). My question is how the max_depth parameter helps on the model. how does high/low max_depth help in predicting the test data more accurately? 回答1: max_depth is what the name suggests: The maximum depth that you allow the tree to grow to. The deeper you allow, the more complex your model will become. For training error, it is

FileNotFoundError rendering decision tree with CHAID

孤街浪徒 提交于 2021-02-11 15:41:18
问题 I used the following code to get the decision tree of CHAID independent_variable_columns = ['gender', 'grade', 'no_renewals', 'complaint_count'] dep_variable = 'switch' tree = Tree.from_pandas_df( df, dict(zip(independent_variable_columns, ['nominal'] * 38)), dep_variable, max_depth=2 ) tree.to_tree() tree.render() but I am getting the following error File "C:\Users\data\AppData\Local\Continuum\anaconda3\lib\site-packages\CHAID\graph.py", line 93, in <listcomp> [os.remove(file) for file in

FileNotFoundError rendering decision tree with CHAID

会有一股神秘感。 提交于 2021-02-11 15:38:59
问题 I used the following code to get the decision tree of CHAID independent_variable_columns = ['gender', 'grade', 'no_renewals', 'complaint_count'] dep_variable = 'switch' tree = Tree.from_pandas_df( df, dict(zip(independent_variable_columns, ['nominal'] * 38)), dep_variable, max_depth=2 ) tree.to_tree() tree.render() but I am getting the following error File "C:\Users\data\AppData\Local\Continuum\anaconda3\lib\site-packages\CHAID\graph.py", line 93, in <listcomp> [os.remove(file) for file in

pydotplus.graphviz.InvocationException: GraphViz's executables not found

♀尐吖头ヾ 提交于 2021-02-11 14:31:12
问题 I tried to run this but I am getting GraphViz's executables not found. I have done pip install graphviz but no success import pandas from sklearn import tree import pydotplus from sklearn.tree import DecisionTreeClassifier import matplotlib.pyplot as plt import matplotlib.image as pltimg df = pandas.read_csv("shows.csv") d = {'UK': 0, 'USA': 1, 'N': 2} df['Nationality'] = df['Nationality'].map(d) d = {'YES': 1, 'NO': 0} df['Go'] = df['Go'].map(d) features = ['Age', 'Experience', 'Rank',

pydotplus.graphviz.InvocationException: GraphViz's executables not found

回眸只為那壹抹淺笑 提交于 2021-02-11 14:28:16
问题 I tried to run this but I am getting GraphViz's executables not found. I have done pip install graphviz but no success import pandas from sklearn import tree import pydotplus from sklearn.tree import DecisionTreeClassifier import matplotlib.pyplot as plt import matplotlib.image as pltimg df = pandas.read_csv("shows.csv") d = {'UK': 0, 'USA': 1, 'N': 2} df['Nationality'] = df['Nationality'].map(d) d = {'YES': 1, 'NO': 0} df['Go'] = df['Go'].map(d) features = ['Age', 'Experience', 'Rank',

partykit: Modify terminal node to include standard deviation and significance of regressors

北城余情 提交于 2021-02-10 16:01:31
问题 I would like to be able to personalize the plot that it is displayed to include standard deviation and statistical significance of the regressors after using the partykit::mob() function. The following code is from partykit documentation. library("partykit") if(require("mlbench")) { ## Pima Indians diabetes data data("PimaIndiansDiabetes", package = "mlbench") ## a simple basic fitting function (of type 1) for a logistic regression logit <- function(y, x, start = NULL, weights = NULL, offset