-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automated Ranger training for a grid of specifications and datasets. …
…Separated export and validation of predictions from training. Switched .RDS files handling to readr package and bz2 algorithm. Partly finished Ranger predictions validation code.
- Loading branch information
Jakub Cierocki
committed
May 9, 2020
1 parent
6fe28ec
commit 961f143
Showing
6 changed files
with
78 additions
and
50 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#### validation and visualisation automating functions | ||
|
||
get_all_metrics <- function(pred_dfs, spec = 1L) { | ||
f <- function(df) metrics(df, Exited, .pred_class, .pred_No) | ||
model1_metrics <- f(pred_dfs[[1]][[spec]]) | ||
|
||
all_metrics <- do.call( | ||
function(...) bind_cols(model1_metrics, ...), | ||
pred_dfs %>% select(-1) %>% map(~ f(.x[[spec]])$.estimate)) %>% | ||
rename(model_1 = .estimate) %>% | ||
return | ||
} | ||
|
||
exportable_conf_matrix <- function(df) { | ||
conf_mat(df, Exited, .pred_class)$table | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#### walidation | ||
|
||
library(tidyverse) | ||
library(stringr) | ||
library(tidymodels) | ||
library(ranger) | ||
library(vip) | ||
library(knitr) | ||
library(kableExtra) | ||
|
||
rm(list = ls()) | ||
|
||
fitted_models <- read_rds("data/fitted_models.RDS") | ||
pred_dfs <- read_rds("data/predictions.RDS") | ||
|
||
source("funs_valid.R") | ||
|
||
all_metrics <- get_all_metrics(pred_dfs) | ||
|
||
pred_dfs[[1]][[1]] %>% exportable_conf_matrix %>% kable(format = "markdown") | ||
|
||
# df_pred_probs1 %>% roc_curve(Exited, .pred_No) %>% autoplot() | ||
# df_pred_probs2 %>% roc_curve(Exited, .pred_No) %>% autoplot() | ||
# | ||
# vi(ranger_model_1) | ||
# vi(ranger_model_2) | ||
# | ||
# vip(ranger_model_1) | ||
# vip(ranger_model_2) |