14.14 Step 8: Save the Model to File
We save the model, together with the dataset and other variables, into a binary R file.
<- "_" %s+% format(Sys.time(), "%Y%m%d_%H%M%S") mddate <- dsname %s+% "_" %s+% mtype %s+% mddate %s+% ".RData" mdrdata save(ds, dsname, tr, te, actual_tr, risk_tr, actual_te, risk_te, per, con, model, mtype,file=mdrdata)
The dataset, its meta-data and the model are now stored in *. We can then load this later and replicate the process.
##  "ds" "dsname" "tr" "te" "actual_tr" "risk_tr" ##  "actual_te" "risk_te" "per" "con" "model" "mtype"
Note that by using generic variable names we can load different model files and perform common operations on them without changing the names within a script. However, do note that each time we load such a saved model file we overwrite any other variables of the same name.
We have also defined some additional meta-data variables relating to modelling and these will be useful to include in the data file with the dataset, separate to the saved model. We augment the original data file with the modelling meta data and save that to a new file.
<- "_" %s+% format(Sys.time(), "%Y%m%d_%H%M%S") mddate <- dsname %s+% "_meta" %s+% mddate %s+% ".RData" mdrdata save(ds, dsname, tr, te, actual_tr, risk_tr, actual_te, risk_te, per, con,file=mdrdata)
The dataset and its meta-data are now stored on our computer in the current folder in a file with the name *.
Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2021 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0