Learn R Programming

modeltime.gluonts (version 0.1.0)

save_gluonts_model: Saving and Loading GluonTS Models

Description

GluonTS models require a special storage process that saves / loads the recipe used to recreate a model to / from a directory that the user defines.

Usage

save_gluonts_model(object, path, overwrite = FALSE)

load_gluonts_model(path)

Arguments

object

A fitted model object

path

A directory to store the GluonTS model files

overwrite

Whether or not to allow overwriting a GluonTS model's directory. Default: FALSE.

Examples

Run this code
# NOT RUN {
library(tidymodels)
library(tidyverse)
library(timetk)

model_fit <- nbeats(

    # User Defined (Required) Parameters
    id                    = "id",
    freq                  = "M",
    prediction_length     = 24,

    # Hyper Parameters
    epochs                = 1,
    num_batches_per_epoch = 4
) %>%
    set_engine("gluonts_nbeats") %>%
    fit(value ~ date + id, m750)

# Saves the related files needed to recreate the model
model_fit %>% save_gluonts_model(path = "/dir_nbeats_model/")

# Loads the model
load_gluonts_model(path = "/dir_nbeats_model/")

# }
# NOT RUN {
# }

Run the code above in your browser using DataLab