View source: R/model_visualize.R
| model_visualize | R Documentation |
Visualizes the current (last) GLM model using charts which may contain observed values, fitted values and values derived
from model coefficients (predictions at base levels). Scale of the y-axis can be controlled using y_axis and rescaled arguments.
model_visualize(
setup,
factors = "fitted",
by = NULL,
y_axis = c("predicted", "linear"),
rescaled = FALSE,
ref_models = NULL
)
setup |
Setup object. Created at the start of the workflow. Usually piped in from previous step. |
factors |
Character scalar/vector. Either one of |
by |
Character scalar. A name of one of currently fitted predictors in the model. Will result in two-way chart showing the combination of the main effects (without interaction). |
y_axis |
Character scalar. Either |
rescaled |
Boolean scalar. Whether the y-axis is rescaled compared to the base level predictor at each chart. |
ref_models |
Character vector. Names of one or multiple reference models created by using |
List of ggplot2 charts.
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()
# this is also the default
modeling %>%
model_visualize(factors = 'fitted', y_axis = 'predicted', rescaled = FALSE)
modeling %>%
model_visualize(factors = 'fitted', y_axis = 'linear', rescaled = TRUE)
modeling %>%
model_visualize(factors = 'unfitted')
modeling %>%
model_visualize(factors = c('pol_yr', 'agecat'))
modeling <- modeling %>%
factor_add(gender) %>%
model_fit()
modeling %>%
model_visualize(factors = 'fitted', by = 'gender')
modeling %>%
model_visualize(factors = 'agecat', by = 'gender', y_axis = 'linear')
modeling <- modeling %>%
model_save('model1') %>%
factor_modify(agecat = variate(agecat, type = 'non_prop', mapping = 1:6, degree = 2)) %>%
model_fit()
modeling %>%
model_visualize(ref_models = "model1")
modeling %>%
model_visualize(y_axis = "linear", ref_models = "model1")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.