library(randomForest)
library(pdp)
data(boston)
set.seed(42)
rf <- randomForest(cmedv ~ ., data = boston)
data <- boston[,-3] # remove target variable
ntrees <- c(4,8,16,32,64,128)
xg <- xgrove(rf, data, ntrees)
xg
plot(xg)
# alternatively, visualize weights for the grove of size 8:
plot(xg, n.trees = 8)
Run the code above in your browser using DataLab