Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dat <- data.frame(y = runif(1000), x=rnorm(1000))
- gbmMod <- gbm::gbm(y~x, data=dat, n.trees=5000, cv.folds=0)
- summary(lm(predict(gbmMod, n.trees=5000) ~ dat$y))$adj.r.squared
- inds <- sample(1:nrow(dat), 0.7*nrow(dat))
- train <- dat[inds, ]
- test <- dat[-inds, ]
- gbmMod2 <- gbm::gbm(y~x, data=train, n.trees=5000)
- preds <- predict(gbmMod2, newdata = test, n.trees=5000)
- summary(lm(preds ~ test[,1]))$adj.r.squared
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement