开发者

printing out tree rules computed from R's randomForest package

开发者 https://www.devze.com 2023-03-02 14:11 出处:网络
I\'m using R\'s randomForest package. Is there a way for me to figure out the splitting rules used at each node in the computed trees?

I'm using R's randomForest package. Is there a way for me to figure out the splitting rules used at each node in the computed trees?

Sample code:

library(randomForest)
mydata = data.frame(output = factor(c(0, 0, 0, 1, 1, 1)), x = c(0, 1, 0, 0, 1, 1), y = c(1, 1, 1, 0, 0, 1))
mydata.rf = randomForest(output ~ ., data = mydata, ntree = 3)

I 开发者_如何学Pythonsuspect it has something to do with mydata.rf$forest$treemap, but I'm not sure.


Ah, answered it myself: I can use the getTree function, described in the pdf documentation.

0

精彩评论

暂无评论...
验证码 换一张
取 消