Last active
April 29, 2016 23:01
-
-
Save apapiu/a0aabb27b85cb954843d24dfaac2f7d5 to your computer and use it in GitHub Desktop.
Random Forest of Xgboosts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# X is the training matrix, y are the labels. | |
library(xgboost) | |
n = 100 | |
nrows = dim(X)[1] | |
nfeats = dim(X)[2] | |
replicate(n, { | |
boot_sample <- sample(1:nrows, replace = TRUE) | |
features_selected <- sample(1:nfeats, sqrt(nfeats)) #seems to work better for bagging | |
model_xgb <- xgboost(data = X[boot_sample, features_selected], label = y[boot_sample]) #choose your params here. | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment