View source: R/model_compare.R
model_compare | R Documentation |
Compares multiple insuRglm models with the current (last) model. The comparison models must be saved using model_save
.
model_compare(setup, type = c("rmse", "nested_model_test"), buckets = 10)
setup |
Setup object. Created at the start of the workflow. Usually piped in from previous step. |
type |
Character scalar. One of 'nested_model_test' or 'rmse'.
'nested_model_test' will produce nested model test in form of matrix of standard error percentages.
'rmse' will produce a plot comparing RMSE across all models (also separately for train and CV if |
Either a matrix-like dataframe of nested model test results or a ggplot2 chart.
model_save
, model_crossval
require(dplyr) # for the pipe operator data('sev_train') setup <- setup( data_train = sev_train, target = 'sev', weight = 'numclaims', family = 'gamma', keep_cols = c('pol_nbr', 'exposure', 'premium') ) modeling <- setup %>% factor_add(pol_yr) %>% model_fit() %>% model_save('model1') %>% factor_add(agecat) %>% model_fit() %>% model_save('model2') %>% factor_modify(agecat = variate(agecat, type = 'non_prop', mapping = c(1, 2, 3, 4, 5, 6))) %>% model_fit() # nested model test of model with and without the agecat modeling %>% model_compare(type = 'nested_model_test') # compare training RMSE on all models so far modeling %>% model_compare(type = 'rmse') # compare both training and CV RMSE on all models modeling_with_cv <- modeling %>% model_crossval(cv_folds = 10, stratified = TRUE) modeling_with_cv %>% model_compare(type = 'rmse')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.