| tidypredict_save | R Documentation |
tidypredict_save() writes a parsed model to a YAML file, and
tidypredict_load() reads one back. Together they persist a model's
prediction formula without needing the original model object, or the package
that fitted it, to be available later.
Use these rather than calling yaml::write_yaml() directly. yaml defaults
to 7 significant digits, which is not enough to represent a split threshold
exactly: a re-loaded tree model can then send rows down a different branch
than the model it was saved from.
tidypredict_save(x, file)
tidypredict_load(file)
x |
A fitted model, or a parsed model from |
file |
Path to write the YAML file to, or read it from. |
tidypredict_save() returns x, invisibly, so it can be used in a pipe.
tidypredict_load() returns a parsed model object.
model <- lm(mpg ~ wt + cyl, data = mtcars)
path <- tempfile(fileext = ".yml")
tidypredict_save(model, path)
loaded <- tidypredict_load(path)
tidypredict_fit(loaded)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.