I use cforest
of the party
package in R to calculate conditional inference trees. Similarly to Random Forest, I would like to retrieve variance explained and the variance importance based on the OOB
data (I read that Random Forest returns variance explained and variable importance based on OOB data). To do so with cforest
I used the following code:
model <- party::cforest(y ~ x1 + x2 + x3 + x4 , data=trainings_set , control=cforest_unbiased(ntree=1000, minsplit=25 , minbucket=8 , mtry=4))
model.pred <- predict(model, type="response" , OOB=TRUE)
R2=1 - sum((trainings_set$y-model.pred)^2)/sum((trainings_set$y-mean(trainings_set$y))^2)
varimp_model=party::varimp(model, conditional = TRUE, threshold = 0.2, OOB = TRUE)
I am interested in whether the command OOB=TRUE
would lead to the model being predicted and variable importance being returned based on the OOB data
of the trainings_set?
I posted this question before under a different title, posting it again (slightly redrafted), I hope someone might be able to provide an answer?
The OOB
parameter in cforest
function is for a logical defining out-of-bag predictions
.
This is only TRUE
when you pass a newdata
parameter in cforest
which is generally a test data frame. If the newdata
parameter is there and you have set OOB=TRUE
, then you will get out-of-bag predictions
on this newdata
.
I hope this clarifies your doubt.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.