explore_target: Explore the target variable

View source: R/explore_target.R

explore_targetR Documentation

Explore the target variable

Description

Helps to explore the distribution of target variable in either visual or tabular form.

Usage

explore_target(
  setup,
  type = c("visual", "tabular"),
  weighted = TRUE,
  exclude_zero = FALSE,
  lower_quantile = 0,
  upper_quantile = 1,
  n_cuts = 20
)

Arguments

setup

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

type

Character scalar. Either visual or tabular.

weighted

Logical scalar. Whether the distribution should be weighted.

exclude_zero

Logical scalar. Whether to exclude records with zero value of target variable.

lower_quantile

Numeric scalar. Lower quantile to include in the distribution analysis.

upper_quantile

Numeric scalar. Upper quantile to include in the distribution analysis.

n_cuts

Integer scalar. Number of cuts in the printed distribution. More cuts means more detailed view.

Value

Either a ggplot2 chart or vector of values printed to console.

See Also

explore_data, explore_corr

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')
)

explore_target(setup)
explore_target(setup, type = 'tabular')
explore_target(setup, type = 'visual')
explore_target(setup, type = 'tabular', exclude_zero = TRUE)
explore_target(setup, type = 'visual', lower_quantile = 0.05, upper_quantile = 0.95)


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