save_models: Save models to disk and load models from disk

Description Usage Arguments Value Examples

View source: R/save_load.R

Description

Note that model objects contain training data, except columns ignored (patient_id in the example below). Therefore, if there is PHI in the training data, the saved model object must be treated as PHI. save_models issues a message saying as much.

Usage

1
2
3
save_models(x, filename = "models.RDS", sanitize_phi = TRUE)

load_models(filename)

Arguments

x

model_list object

filename

File path to save model to or read model from, e.g. "models/my_models.RDS". Default for save_models is "models.RDS" in the working directory (getwd()). Default for load_models is to open a dialog box from which a file can be selected, in which case a message will issued with code to load the same file without interactivity.

sanitize_phi

Logical. If TRUE (default) training data is removed from the model object before being saved. Removing training data is important when sharing models that were trained with data that contain PHI. If removed, explore will not have data to process.

Value

load_models returns the model_list which can be assigned to any variable name

Examples

1
2
3
4
5
6
7
8
## Not run: 
m <- machine_learn(pima_diabetes, patient_id, outcome = diabetes)
save_models(m, "diabetes_models.RDS")
# Restart R, move RDS file to another computer, etc.
m2 <- load_models("diabetes_models.RDS")
all.equal(m, m2)

## End(Not run)

healthcareai documentation built on Dec. 13, 2018, 1:04 a.m.