Created
August 7, 2019 23:14
-
-
Save necronet/c3c9aa8ce5c9c2a9a57a251f231233df to your computer and use it in GitHub Desktop.
Create multiple bagging trees and capture each RSME in order to graph the reduce in variance
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
errors <- vector() | |
for ( i in seq(from = 1, to = 50) ) { | |
print(paste('Bagging with',i,'trees')) | |
ames_bag_i <- bagging( formula = Sale_Price ~ ., data=ames_training, nbagg = i, control = rpart.control(minsplit = 2, cp = 0)) | |
errors <- c(errors, ames_bag_i$err) | |
} | |
error_df <- as.data.frame(errors) | |
error_df$n_trees <- 1:nrow(error_df) | |
ggplot(data = error_df, aes(x = n_trees, y = errors)) + geom_line() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment