Learn R Programming

PriceIndices (version 0.0.6)

load_model: Loading the machine learning model from the disk

Description

This function loads a list of machine learning model elements from the disk, i.e. the needed 8 files are read.

Usage

load_model(dir = "ML_model")

Arguments

dir

The name of the directory from which the machine learning model is to be loaded. The directory must be in the working directory.

Value

This function loads a list of ML model elements from the disk, i.e. the needed 8 files are read from the directory selected by dir. After loading the model it can be used for product classification by using data_classifying function.

Examples

Run this code
# NOT RUN {
#Setting a temporal directory as a working directory
# }
# NOT RUN {
wd<-tempdir()
# }
# NOT RUN {
setwd(wd)
# }
# NOT RUN {
#Building the model
# }
# NOT RUN {
my.grid=list(eta=c(0.01,0.02,0.05),subsample=c(0.5))
# }
# NOT RUN {
data_train<-dplyr::filter(dataCOICOP,dataCOICOP$time<=as.Date("2020-08-01"))
# }
# NOT RUN {
data_test<-dplyr::filter(dataCOICOP,dataCOICOP$time>as.Date("2020-08-01"))
# }
# NOT RUN {
ML<-model_classification(data_train,data_test,grid=my.grid,
indicators=c("prodID","unit","description"),key_words=c("milk"),rounds=50)
# }
# NOT RUN {
#Saving the model
# }
# NOT RUN {
save_model(ML, dir="My_model")
# }
# NOT RUN {
#Loading the model
# }
# NOT RUN {
ML_fromPC<-load_model("My_model")
# }
# NOT RUN {
#COICOP predicting
# }
# NOT RUN {
data_classifying(ML_fromPC, data_test)
# }

Run the code above in your browser using DataLab