| register_model | R Documentation |
Adds a model to the package's pluggable registry, keyed by key. Every
model implements the same three-function contract (fit/forecast/
to_tibble), so once registered it works everywhere in the bundled app
(Model tab, Compare Selected Models, Cross-Validation, the Backtest
Leaderboard, the Show Code panel) with no other code changes.
register_model(
key,
label,
fit,
forecast,
to_tibble,
supports_holidays = FALSE,
requires = NULL,
annotate = NULL
)
key |
Character scalar, a unique registry key (e.g. |
label |
Character scalar, the human-readable name shown in the UI. |
fit |
Function with signature |
forecast |
Function with signature |
to_tibble |
Function with signature
|
supports_holidays |
Logical; whether |
requires |
Character scalar naming an optional package this model
needs (e.g. |
annotate |
Optional function with signature |
TRUE, invisibly.
register_model(
key = "naive_last",
label = "Naive (last value)",
fit = function(train_df, date_agg = "day", ...) utils::tail(train_df$y, 1),
forecast = function(model_obj, h, ...) list(mean = rep(model_obj, h)),
to_tibble = function(fc_obj, test_df) {
tibble::tibble(ds = test_df$ds[seq_along(fc_obj$mean)], yhat = fc_obj$mean)
}
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.