Skip to content

Instantly share code, notes, and snippets.

@sfirke
Created March 16, 2017 16:18
Show Gist options
  • Save sfirke/37c937e20cb3ebb2e46905930a0f0489 to your computer and use it in GitHub Desktop.
Save sfirke/37c937e20cb3ebb2e46905930a0f0489 to your computer and use it in GitHub Desktop.
making final Kaggle March Mania predictions
final_blank <- read_csv("data/kaggle/SampleSubmission.csv") %>%
separate(Id, into = c("year", "lower_team", "higher_team"), sep = "_", convert = TRUE, remove = FALSE) %>%
dplyr::select(-Pred)
final_blank_with_data <- final_blank %>%
add_kp_data %>%
create_vars_for_prediction %>%
mutate(lower_team_court_adv = as.factor("N")) %>%
dplyr::select(contains("diff"), lower_team_court_adv, contains("rank")) %>%
dplyr::select(-lower_pre_seas_rank_all, -higher_pre_seas_rank_all)
levels(final_blank_with_data$lower_team_court_adv) <- c("N", "H", "A") # to make levels match the training set
final_preds_1 <- predict(glm_model, final_blank_with_data, type = "prob")[, 2]
final_preds_2 <- predict(rf_model, final_blank_with_data, type = "prob")[, 2]
final_preds_1 <- read_csv("data/kaggle/SampleSubmission.csv") %>% # re-read to get the 3-part Kaggle unique game code
mutate(Pred = final_preds_1)
final_preds_2 <- read_csv("data/kaggle/SampleSubmission.csv") %>% # re-read to get the 3-part Kaggle unique game code
mutate(Pred = final_preds_2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment