vetiver_compute_metrics | R Documentation |
These three functions can be used for model monitoring (such as in a monitoring dashboard):
vetiver_compute_metrics()
computes metrics (such as accuracy for a
classification model or RMSE for a regression model) at a chosen time
aggregation period
vetiver_pin_metrics()
updates an existing pin storing model metrics
over time
vetiver_plot_metrics()
creates a plot of metrics over time
vetiver_compute_metrics(
data,
date_var,
period,
truth,
estimate,
...,
metric_set = yardstick::metrics,
every = 1L,
origin = NULL,
before = 0L,
after = 0L,
complete = FALSE
)
data |
A |
date_var |
The column in |
period |
A string defining the period to group by. Valid inputs can be roughly broken into:
|
truth |
The column identifier for the true results (that
is |
estimate |
The column identifier for the predicted results
(that is also |
... |
A set of unquoted column names or one or more
|
metric_set |
A |
every |
The number of periods to group together. For example, if the period was set to |
origin |
The reference date time value. The default when left as This is generally used to define the anchor time to count from, which is
relevant when the every value is |
before , after |
The number of values before or after the current element to
include in the sliding window. Set to |
complete |
Should the function be evaluated on complete windows only? If |
For arguments used more than once in your monitoring dashboard,
such as date_var
, consider using
R Markdown parameters
to reduce repetition and/or errors.
A dataframe of metrics.
vetiver_pin_metrics()
, vetiver_plot_metrics()
library(dplyr)
library(parsnip)
data(Chicago, package = "modeldata")
Chicago <- Chicago %>% select(ridership, date, all_of(stations))
training_data <- Chicago %>% filter(date < "2009-01-01")
testing_data <- Chicago %>% filter(date >= "2009-01-01", date < "2011-01-01")
monitoring <- Chicago %>% filter(date >= "2011-01-01", date < "2012-12-31")
lm_fit <- linear_reg() %>% fit(ridership ~ ., data = training_data)
library(pins)
b <- board_temp()
original_metrics <-
augment(lm_fit, new_data = testing_data) %>%
vetiver_compute_metrics(date, "week", ridership, .pred, every = 4L)
new_metrics <-
augment(lm_fit, new_data = monitoring) %>%
vetiver_compute_metrics(date, "week", ridership, .pred, every = 4L)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.