Created
February 14, 2020 16:07
-
-
Save timcdlucas/94ef8d8cb652f7f35403cd6ade23da49 to your computer and use it in GitHub Desktop.
Get the out of sample predictions from the best set of hyperparameters
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
get_preds <- function(t){ | |
stopifnot(inherits(t, 'train')) | |
oos <- t$pred %>% arrange(rowIndex) | |
row_matches <- sapply(1:length(t$bestTune), function(x) oos[, names(t$bestTune)[x]] == t$bestTune[[x]]) | |
best_rows <- rowMeans(row_matches) == 1 | |
d <- oos[best_rows, ] | |
return(as.numeric(d$pred)) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment