save_model: Saving the machine learning model on the disk

save_modelR Documentation

Saving the machine learning model on the disk

Description

This function saves a list of machine learning model elements on the disk, i.e. the resulting 8 files are written.

Usage

save_model(model = list(), dir = "ML_model")

Arguments

model

A list of 8 elements which identify the previously built machine learning model (the list is obtained via the model_classification function).

dir

The name of the directory where the selected model should be saved. The directory with all necessary files will be created in the working directory.

Value

This function saves a list of ML model elements on the disk, i.e. the resulting 8 files are written into the new directory specified by dir. The list should be obtained previously using the model_classification function. After saving the model, it can be loaded at any time by using the load_model function.

Examples

#Setting a temporal directory as a working director
## Not run: wd<-tempdir()
## Not run: setwd(wd)
#Building the model
#Building the model
my.grid=list(eta=c(0.01,0.02,0.05),subsample=c(0.5,0.8))
data_train<-dplyr::filter(dataCOICOP,dataCOICOP$time<=as.Date("2021-10-01"))
data_test<-dplyr::filter(dataCOICOP,dataCOICOP$time==as.Date("2021-11-01"))
ML<-model_classification(data_train,data_test,coicop="coicop6",grid=my.grid,
indicators=c("description","codeIN", "grammage"),key_words=c("uht"),rounds=60)
#Saving the model
## Not run: save_model(ML, dir="My_model")

PriceIndices documentation built on July 9, 2023, 6:20 p.m.