modeltime_accuracy: Calculate Accuracy Metrics

Description Usage Arguments Details Value Examples

View source: R/modeltime-accuracy.R

Description

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).

Usage

1
2
3
4
5
6
7
modeltime_accuracy(
  object,
  new_data = NULL,
  metric_set = default_forecast_accuracy_metric_set(),
  quiet = TRUE,
  ...
)

Arguments

object

A Modeltime Table

new_data

A tibble to predict and calculate residuals on. If provided, overrides any calibration data.

metric_set

A yardstick::metric_set() that is used to summarize one or more forecast accuracy (regression) metrics.

quiet

Hide errors (TRUE, the default), or display them as they occur?

...

Not currently used

Details

The following accuracy metrics are included by default via default_forecast_accuracy_metric_set():

Value

A tibble with accuracy estimates.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
library(tidymodels)
library(tidyverse)
library(lubridate)
library(timetk)

# Data
m750 <- m4_monthly %>% filter(id == "M750")

# Split Data 80/20
splits <- initial_time_split(m750, prop = 0.9)

# --- MODELS ---

# Model 1: auto_arima ----
model_fit_arima <- arima_reg() %>%
    set_engine(engine = "auto_arima") %>%
    fit(value ~ date, data = training(splits))


# ---- MODELTIME TABLE ----

models_tbl <- modeltime_table(
    model_fit_arima
)

# ---- ACCURACY ----

models_tbl %>%
    modeltime_calibrate(new_data = testing(splits)) %>%
    modeltime_accuracy(
        metric_set = metric_set(mae, rmse, rsq)
    )

modeltime documentation built on June 13, 2021, 5:06 p.m.