party

R randomForest - how to predict with a “getTree” tree

不羁的心 提交于 2020-01-24 14:23:08
问题 Background: I can make a random Forest in R: set.seed(1) library(randomForest) data(iris) model.rf <- randomForest(Species ~ ., data=iris, importance=TRUE, ntree=20, mtry = 2) I can predict values using the randomForest object that I just made: my_pred <- predict(model.rf) plot(iris$Species,my_pred) I can then peel off some random tree from the forest: idx <- sample(x = 1:20,size = 1,replace = F) single_tree <- getTree(model.rf,k=1) Questions: How do I predict from a single tree pulled from

R randomForest - how to predict with a “getTree” tree

自作多情 提交于 2020-01-24 14:22:25
问题 Background: I can make a random Forest in R: set.seed(1) library(randomForest) data(iris) model.rf <- randomForest(Species ~ ., data=iris, importance=TRUE, ntree=20, mtry = 2) I can predict values using the randomForest object that I just made: my_pred <- predict(model.rf) plot(iris$Species,my_pred) I can then peel off some random tree from the forest: idx <- sample(x = 1:20,size = 1,replace = F) single_tree <- getTree(model.rf,k=1) Questions: How do I predict from a single tree pulled from

Ctree classification with weights - results displayed

懵懂的女人 提交于 2020-01-15 09:09:55
问题 Let's say I want to use the iris data example, but correctly classifying versicolor is 5 times more important to me. library(party) data(iris) irisct <- ctree(Species ~ .,data = iris, weights=ifelse(iris$Species=='versicolor', 5, 1)) plot(irisct) Then the tree graph changes the number of observations and conditional probabilities in each node (it multiplies versicolor by 5). Is there a way to "disable" this, i.e. show the original number of observations (total = 150 for iris)? Many thanks for

Ctree classification with weights - results displayed

房东的猫 提交于 2020-01-15 09:08:20
问题 Let's say I want to use the iris data example, but correctly classifying versicolor is 5 times more important to me. library(party) data(iris) irisct <- ctree(Species ~ .,data = iris, weights=ifelse(iris$Species=='versicolor', 5, 1)) plot(irisct) Then the tree graph changes the number of observations and conditional probabilities in each node (it multiplies versicolor by 5). Is there a way to "disable" this, i.e. show the original number of observations (total = 150 for iris)? Many thanks for

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

How to specify split in a decision tree in R programming?

扶醉桌前 提交于 2019-12-29 07:14:31
问题 I am trying to apply decision tree here. Decision tree takes care of splitting at each node itself. But at first node I want to split my tree on the basis of "Age". How do I force that.? library(party) fit2 <- ctree(Churn ~ Gender + Age + LastTransaction + Payment.Method + spend + marStat, data = tsdata) 回答1: There is no built-in option to do that in ctree() . The easiest method to do this "by hand" is simply: Learn a tree with only Age as explanatory variable and maxdepth = 1 so that this

Displaying inference tree node values with “print”

狂风中的少年 提交于 2019-12-24 05:08:05
问题 I apologize in advance if I butcher this question as I'm very new to R and statistical analysis in general. I've generated a conditional inference tree using the party library. When I plot(my_tree, type = "simple") I get a result like this: When I print(my_tree) I get a result like this: 1) SOME_VALUE <= 2.5; criterion = 1, statistic = 1306.478 2) SOME_VALUE <= -10.5; criterion = 1, statistic = 173.416 3) SOME_VALUE <= -16; criterion = 1, statistic = 19.385 4)* weights = 275 3) SOME_VALUE >

“'Calloc 'could not allocate memory” in 64-bit R

醉酒当歌 提交于 2019-12-19 17:47:45
问题 I'm on Windows Server 2012 (64-bit) with 30.5 GB of RAM, running R v3.1.2 in RStudio 0.98, and am still having trouble with R hitting a memory limit. I reviewed the FAQ here: http://cran.r-project.org/bin/windows/base/rw-FAQ.html#There-seems-to-be-a-limit-on-the-memory-it-uses_0021 Which states that the memory limit on 64-bit instances defaults to the total amount of RAM, and that the limit can be checked and set using memory.limit(). A call to memory.limit() returns 31249 , confirming that

How to extract the splitting rules for the terminal nodes of ctree()

北城以北 提交于 2019-12-19 04:38:28
问题 I have a data set with 6 categorical variables with levels ranging from 5 to 28. I have obtained an output from ctree() (party package) with 17 terminal nodes. I have followed the inputs by @Galled from ctree() - How to get the list of splitting conditions for each terminal node? to arrive at my desired output. But, I'm getting the following error post running the code: Error in data.frame(ResulTable, Means, Counts) : arguments imply differing number of rows: 17, 2 I have tried adding this