开发者

printing out tree rules computed from R's randomForest package

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜