View source: R/modeltime-accuracy.R
modeltime_accuracy | R Documentation |
This is a wrapper for yardstick
that simplifies time series regression accuracy metric
calculations from a fitted workflow
(trained workflow) or model_fit
(trained parsnip model).
modeltime_accuracy(
object,
new_data = NULL,
metric_set = default_forecast_accuracy_metric_set(),
acc_by_id = FALSE,
quiet = TRUE,
...
)
object |
A Modeltime Table |
new_data |
A |
metric_set |
A |
acc_by_id |
Should a global or local model accuracy be produced? (Default: FALSE)
|
quiet |
Hide errors ( |
... |
If |
The following accuracy metrics are included by default via default_forecast_accuracy_metric_set()
:
MAE - Mean absolute error, mae()
MAPE - Mean absolute percentage error, mape()
MASE - Mean absolute scaled error, mase()
SMAPE - Symmetric mean absolute percentage error, smape()
RMSE - Root mean squared error, rmse()
RSQ - R-squared, rsq()
A tibble with accuracy estimates.
library(tidymodels)
library(dplyr)
library(lubridate)
library(timetk)
# Data
m750 <- m4_monthly %>% filter(id == "M750")
# Split Data 80/20
splits <- initial_time_split(m750, prop = 0.8)
# --- MODELS ---
# Model 1: prophet ----
model_fit_prophet <- prophet_reg() %>%
set_engine(engine = "prophet") %>%
fit(value ~ date, data = training(splits))
# ---- MODELTIME TABLE ----
models_tbl <- modeltime_table(
model_fit_prophet
)
# ---- ACCURACY ----
models_tbl %>%
modeltime_calibrate(new_data = testing(splits)) %>%
modeltime_accuracy(
metric_set = metric_set(mae, rmse, rsq)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.