Created
May 22, 2015 16:47
-
-
Save DexGroves/9d821dde795108a09f51 to your computer and use it in GitHub Desktop.
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
benchmark_scoring <- function(repetitions, rows, n.trees){ | |
# Score a n.trees gbm on rows, repetitions times, and time it. | |
library("gbm") | |
y <- seq(1, 2, length.out = rows) | |
number_x <- runif(rows) | |
factor_x <- sample(letters, replace = TRUE, size = rows) | |
factor_2 <- sample(LETTERS, replace = TRUE, size = rows) | |
g <- gbm(y ~ number_x + factor_x, | |
data = data.frame(y, number_x, factor_x), | |
n.trees = n.trees) | |
system.time(replicate(repetitions, predict(g, n.trees = n.trees))) | |
} | |
## Uncomment gbm source as appropriate | |
# devtools::install_github("gbm-developers/gbm") | |
# install.packages("gbm", repos = "http://cran.rstudio.com/") | |
benchmark_scoring(10, 1e4, 1e4) | |
# Takes ~ 85 seconds with github gbm and ~ 25 seconds with CRAN for me |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment