## Fit a random forest (using cforest)
set.seed(290875)
readingSkills.cf <- party::cforest(score ~ ., data = party::readingSkills,
control = party::cforest_unbiased(mtry = 2, ntree = 50))
## compute permutation variable importance:
set.seed(290875)
permVIM <- permimp(readingSkills.cf)
## print the variable importance values
permVIM
print(permVIM, ranks = TRUE)
ranks(permVIM)
## Visualize the variable importance values
plot(permVIM, type = "bar", margin = c(6,3,3,1))
plot(permVIM, nVar = 2, type = "box", horizontal = TRUE)
## note the rankings
plot(subset(permVIM, c("age", "nativeSpeaker")), intervalColor = "pink")
plot(subset(permVIM, c("shoeSize", "nativeSpeaker")), intervalColor = "pink")
Run the code above in your browser using DataLab