decision-tree

How to implement an interactive decision tree in C#

寵の児 提交于 2020-01-23 02:05:07
问题 I need to allow the users choose their own path by picking between two simple choices displayed on their screen in order to progress to the next set of choices, until they get to one of the endings, i.e something like this should be achieved: I have tried the following code, but only the left side is evaluated each time. I am wondering how can I achieve a results like the above image (covering all the branches)? For instance, if the user selects "No" the application shouldn't ask any further

How to prune a tree in R?

给你一囗甜甜゛ 提交于 2020-01-20 03:17:28
问题 I'm doing a classification using rpart in R. The tree model is trained by: > tree <- rpart(activity ~ . , data=trainData) > pData1 <- predict(tree, testData, type="class") The accuracy for this tree model is: > sum(testData$activity==pData1)/length(pData1) [1] 0.8094276 I read a tutorial to prune the tree by cross validation: > ptree <- prune(tree,cp=tree$cptable[which.min(tree$cptable[,"xerror"]),"CP"]) > pData2 <- predict(ptree, testData, type="class") The accuracy rate for the pruned tree

Method of finding threshold in Decision tree for continuous data

别说谁变了你拦得住时间么 提交于 2020-01-17 05:02:20
问题 I am using decision tree in Weka and I have some continuous data, so when I use Weka it automatically find the threshold for me but for some reason I want to implement Decision Tree by myself so I need to know what approach to use to find the threshold to discretize my continuous data? 回答1: ID3 and C4.5 use entropy heuristic for discretization of continuous data. The method finds a binary cut for each variable (feature). You could apply the same method recursively to get multiple intervals

How to interpret decision trees' graph results and find most informative features?

纵然是瞬间 提交于 2020-01-16 06:35:00
问题 I am using sk-learn python 27 and have output some decision tree feature results. Though I am not sure how to interpret the results. At first, I thought the features are listed from the most informative to least informative (from top to bottom), but examining the \nvalue it suggests otherwise. How do I identify the top 5 most informative features from the outputs or using python lines? from sklearn import tree tree.export_graphviz(classifierUsed2, feature_names=dv.get_feature_names(), out

What libraries for modeling complex questionaire in Python?

烈酒焚心 提交于 2020-01-13 03:42:26
问题 For a medical website I'm trying to model a questionnaire that should result in a range of possible diagnoses. The questionnaire is fairly complex with a lot of conditionals. I made a flowchart/decision tree to reflect this questionnaire. I'm using Django to make the website. Currently I'm thinking of using Python Graph to turn the flow chart into a weighted graph. Each question would be a node and each answer would be an edge+label. I could then walk through the complete graph and the

Why the decision tree structure is only binary tree for sklearn DecisionTreeClassifier?

﹥>﹥吖頭↗ 提交于 2020-01-11 06:00:08
问题 As we can see from the sklearn document here, or from my experiment, all the tree structure of DecisionTreeClassifier is binary tree. Either the criterion is gini or entropy, each DecisionTreeClassifier node can only has 0 or 1 or 2 child node. But from the decision tree introduction slide(page 3), each node of theoretic decision tree can has more than 2 child node. So my question is why the decision tree structure is only binary tree (each DecisionTreeClassifier node can only has 1 or 2

How to count the observations falling in each node of a tree

倖福魔咒の 提交于 2020-01-10 11:48:33
问题 I am currently dealing with wine data in MMST package. I have split the whole dataset into training and test and build a tree like the following codes: library("rpart") library("gbm") library("randomForest") library("MMST") data(wine) aux <- c(1:178) train_indis <- sample(aux, 142, replace = FALSE) test_indis <- setdiff(aux, train_indis) train <- wine[train_indis,] test <- wine[test_indis,] #### divide the dataset into trainning and testing model.control <- rpart.control(minsplit = 5, xval =

Extract All Possible Paths from Expression-Tree and evaluate them to hold TRUE

巧了我就是萌 提交于 2020-01-04 05:39:09
问题 This is a follow-up question of my previous one: Better Class-Structure for logical expression parsing and evaluation Brief introduction: rules as strings combinations of logical-and , logical-or , logical-negation and grouping by parenthesis of identifiers (ID's) Example: "{100} AND (({101} OR {102}) OR ({103} AND {104})) AND NOT ({105} OR {106})" This gets currently evaluated into a binary-tree of nodes, that looks like this: Code taken from here: How to parse a boolean expression and load

Rotate Classification Tree Terminal Barplot axis - R

六月ゝ 毕业季﹏ 提交于 2020-01-02 17:55:12
问题 I have a classification tree analyzed using ctree() was wondering how can one rotate the terminal nodes so that the axes are vertical? library(party) data(iris) attach(iris) plot(ctree(Species ~ Sepal.Length + Sepel.Width + Petal.Length + Petal.Width, data = iris)) 回答1: Here is how I would go about it. Not the shortest answer, but I wanted to be as thorough as possible. Since we are plotting your tree, it's probably a good idea to look at the documentation for the appropriate plotting

Rotate Classification Tree Terminal Barplot axis - R

﹥>﹥吖頭↗ 提交于 2020-01-02 17:55:11
问题 I have a classification tree analyzed using ctree() was wondering how can one rotate the terminal nodes so that the axes are vertical? library(party) data(iris) attach(iris) plot(ctree(Species ~ Sepal.Length + Sepel.Width + Petal.Length + Petal.Width, data = iris)) 回答1: Here is how I would go about it. Not the shortest answer, but I wanted to be as thorough as possible. Since we are plotting your tree, it's probably a good idea to look at the documentation for the appropriate plotting