decision-tree

R decision tree using all the variables

我的梦境 提交于 2019-12-08 08:45:39
问题 I would like to perform a decision tree analysis. I want that the decision tree uses all the variables in the model. I also need to plot the decision tree. How can I do that in R? This is a sample of my dataset > head(d) TargetGroup2000 TargetGroup2012 SmokingGroup_Kai PA_Score wheeze3 asthma3 tres3 1 2 2 4 2 0 0 0 2 2 2 4 3 1 0 0 3 2 2 5 1 0 0 0 4 2 2 4 2 1 0 0 5 2 3 3 1 0 0 0 6 2 3 3 2 0 0 0 > I would like to use the formula myFormula <- wheeze3 ~ TargetGroup2000 + TargetGroup2012 +

Check all elements of a list (Drools Expert)

萝らか妹 提交于 2019-12-08 06:46:07
问题 I'm trying to write rules in Drools Expert. In the when part of the rule, I check some properties of an Application object. This object contains a List and I would like to check if a bunch of rules apply to all objects of SomeOtherType in this list. The rule should fire only when the constraints are valid for ALL objects in that list. rule "Application eligible" when app : Application( some constrains & write some constraints for all objects in app.getList() (a method that returns a List

as_formula specifier for sklearn.tree.decisiontreeclassifier in Python?

久未见 提交于 2019-12-08 03:06:32
问题 I was curious if there is an as_formula specifier (like in statsmodels ) for sklearn.tree.decisiontreeclassifier in Python, or some way to hack one in. Currently, I must use clf = tree.DecisionTreeClassifier() clf = clf.fit(X, Y) but I would prefer to have something like clf = clf.fit(formula='Y ~ X', data=df) The reason is that I would like to specify more than one X without having to do a lot of array shaping. Thanks. 回答1: It's currently not possible, but it would be great to have a patsy

Extract rule path of data point through decision tree with sklearn python

こ雲淡風輕ζ 提交于 2019-12-08 00:38:56
问题 I'm using decision tree model and I want to extract the decision path for each data point in order to understand what caused the Y rather than to predict it. How can I do that? Couldn't find any documentation. 回答1: Here is an example using the iris dataset . from sklearn.datasets import load_iris from sklearn import tree import graphviz iris = load_iris() clf = tree.DecisionTreeClassifier() clf = clf.fit(iris.data, iris.target) dot_data = tree.export_graphviz(clf, out_file=None, feature_names

Plot decision tree in R (Caret)

断了今生、忘了曾经 提交于 2019-12-07 16:05:32
问题 I have trained a dataset with rf method. For example: ctrl <- trainControl( method = "LGOCV", repeats = 3, savePred=TRUE, verboseIter = TRUE, preProcOptions = list(thresh = 0.95) ) preProcessInTrain<-c("center", "scale") metric_used<-"Accuracy" model <- train( Output ~ ., data = training, method = "rf", trControl = ctrl, metric=metric_used, tuneLength = 10, preProc = preProcessInTrain ) After thath, I want to plot the decission tree, but when I wirte plot(model) , I get this: plot(model). If

How do I visualise / plot a decision tree in Apache Spark (PySpark 1.4.1)?

妖精的绣舞 提交于 2019-12-07 06:53:58
问题 I am using Apache Spark Mllib 1.4.1 (PySpark, the python implementation of Spark) to generate a decision tree based on LabeledPoint data I have. The tree generates correctly and I can print it to the terminal (extract the rules as this user calls it How to extract rules from decision tree spark MLlib) using: model = DecisionTree.trainClassifier( ... ) print(model.toDebugString() But what I want to do is visualize or plot the decision tree rather than printing it to the terminal. Is there any

Decision Analysis in R [closed]

倖福魔咒の 提交于 2019-12-07 05:30:45
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . I teach courses on business decision-making and more most of the analytic techniques I work with I am working with R. As well, in my

in R: Error in is.data.frame(data) : object '' not found, C5.0 plot

房东的猫 提交于 2019-12-07 04:49:42
问题 This question is similar to some other questions on Stackoverflow (here, here and here), but different enough so that I cannot extrapolate those answers to my case. I have a function in which I fit a C5.0 model and than try to plot the model. train_d <- globald[train_ind,c(features,21)] model <- C5.0(binclass ~ .,data=train_d,trials=10) binclass is a column name in my training/test data (globald is a dataframe from which I subset rows with _ind indices and columns c(3:12,21) , where column 21

Inference engines vs Decision trees [closed]

為{幸葍}努か 提交于 2019-12-07 00:57:19
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . I am using an expert system with an inference engine (forward chaining) and I would like to explain why it is better than a decision tree using very simple concepts. (in one particular situation) I know there is a similar question on stackoverflow but it's not the answer I'm

pydot: is it possible to plot two different nodes with the same string in them?

随声附和 提交于 2019-12-06 20:59:56
问题 I'm using pydot in order to draw graphs in python. I'd like to represent a decision tree, say something like (a1,a2,a3 are attributes and two classes are 0 and 1: a1>3 / \ a2>10 a3>-7 / \ / \ 1 0 1 0 However, using pydot, only two leaves are created and the tree looks like this (png attached): a1>3 / \ a2>10 a3>-7 | X | 1 0 Now, in this simple case the logic is fine but in larger trees it is messy internal nodes belonging to different branches are unified. The simple code I'm using is: import