xgboostでランダムフォレストを実行する
xgboostでランダムフォレストを実行できる。
nrounds=1にして、subsampleとcolsampleをお好みの割合に設定した後、num_parallel_treeで木の数を指定すればよい。
たとえばcaretからxgboostでclassificationを行う場合以下のような設定になる。
library("caret") model_rf <- train( target_var~., sampledata, method="xgbTree", metric="ROC", colsample_bytree=0.3, subsample=0.632, num_parallel_tree=1000, tuneGrid=expand.grid(max_depth = 15, nrounds = 1, eta = 0.1) )
xgboostのvignetteを読めば書いてあることだが、一応メモとして残しておく。
https://github.com/dmlc/xgboost/blob/master/R-package/vignettes/discoverYourData.Rmd#special-note-what-about-random-forests
ただし、実験的な実装と書いてあるのでいつまであるものかわからないしkaggleのforumを読む限りxgboostの開発者はわざわざランダムフォレストを使うことを推奨していないように思える。