model_lift: Visualize the lift of insuRglm models

View source: R/model_lift.R

model_liftR Documentation

Visualize the lift of insuRglm models

Description

Visualize the lift chart of one or all saved insuRglm models. The records are first ordered by predictions in ascending order and then divided roughly into several buckets (groups). Average of target variable is computed and displayed for each group separately.

Usage

model_lift(
  setup,
  data = c("train", "crossval"),
  model = c("current", "all"),
  buckets = 10,
  weighted = TRUE
)

Arguments

setup

Setup object. Created at the start of the workflow. Usually piped in from previous step.

data

Character scalar. Either train or crossval. The latter requires running model_crossval first.

model

Character scalar. Either current or all. The latter will display the current and all saved models.

buckets

Integer scalar. Number of groups to divide data into.

weighted

Boolean scalar. Whether the average of target variable in each group should be weighted.

Value

List of one or more ggplo2 charts.

See Also

model_save, model_crossval

Examples

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) %>%
  factor_add(agecat) %>%
  model_fit()

modeling %>%
  model_lift(data = 'train', buckets = 10)

modeling_cv <- modeling %>%
  model_crossval()

modeling_cv %>%
  model_lift(data = 'crossval', buckets = 5)


realgabon/insuRglm documentation built on Jan. 2, 2023, 2:51 a.m.