NB
model run, which took 2.9 hoursload("~/DFS/kaggle/slow.RData") # `WFinalFour` is the teams / ID table # `nb_model` is the `mvglmmRank` model
library(dplyr) library(tibble) library(mvglmmRank) library(knitr)
mvglmmRank::game.pred
output.get_number <- function(text) as.numeric(sub(pattern = "^.*: ", replacement = "", text))
predictions <- tibble() for (irow in 1:3) { for (jrow in (irow + 1):4) { team1_id <- as.character(WFinalFour$TeamID[irow]) team2_id <- as.character(WFinalFour$TeamID[jrow]) game_prediction <- capture.output(game.pred( nb_model, team1_id, team2_id, neutral.site = TRUE)) pred_score_1 <- .get_number(game_prediction[2]) pred_score_2 <- .get_number(game_prediction[3]) spread_1 <- pred_score_2 - pred_score_1 spread_2 <- pred_score_1 - pred_score_2 over_under <- pred_score_1 + pred_score_2 win_prob_1 <- .get_number(game_prediction[9]) win_prob_2 <- 1 - win_prob_1 predictions <- predictions %>% bind_rows(tibble( team_1 = WFinalFour$TeamName[irow], team_2 = WFinalFour$TeamName[jrow], pred_score_1, pred_score_2, spread_1, spread_2, over_under, win_prob_1, win_prob_2 )) } } kable(predictions)
sessionInfo()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.