diff --git a/NAMESPACE b/NAMESPACE index 98ed3436..f8553dbc 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -346,6 +346,7 @@ importFrom(dplyr,summarise) importFrom(dplyr,transmute) importFrom(dplyr,ungroup) importFrom(dplyr,vars) +importFrom(generics,accuracy) importFrom(generics,augment) importFrom(generics,components) importFrom(generics,equation) diff --git a/R/accuracy.R b/R/accuracy.R index a870cfa8..f5c552d1 100644 --- a/R/accuracy.R +++ b/R/accuracy.R @@ -413,20 +413,12 @@ skill_score <- function(measure) { #' used to train the model. #' #' @param object A model or forecast object +#' @param measures A list of accuracy measure functions to compute (such as [`point_accuracy_measures`], [`interval_accuracy_measures`], or [`distribution_accuracy_measures`]) #' @param ... Additional arguments to be passed to measures that use it. #' #' @seealso #' [Evaluating forecast accuracy](https://otexts.com/fpp3/accuracy.html) #' -#' @export -accuracy <- function(object, ...){ - UseMethod("accuracy") -} - -#' @rdname accuracy -#' -#' @param measures A list of accuracy measure functions to compute (such as [`point_accuracy_measures`], [`interval_accuracy_measures`], or [`distribution_accuracy_measures`]) -#' #' @examplesIf requireNamespace("fable", quietly = TRUE) && requireNamespace("tsibbledata", quietly = TRUE) #' library(fable) #' library(tsibble) @@ -456,6 +448,7 @@ accuracy <- function(object, ...){ #' measures = list(interval_accuracy_measures, distribution_accuracy_measures) #' ) #' +#' @rdname accuracy #' @export accuracy.mdl_df <- function(object, measures = point_accuracy_measures, ...){ if(is_tsibble(measures)){ @@ -468,6 +461,7 @@ Hint: A tsibble of future values is only required when computing accuracy of a f unnest_tbl("fit") } +#' @rdname accuracy #' @export accuracy.mdl_ts <- function(object, measures = point_accuracy_measures, ...){ dots <- dots_list(...) diff --git a/R/reexports.R b/R/reexports.R index 2bb0dcce..b6da2b87 100644 --- a/R/reexports.R +++ b/R/reexports.R @@ -17,6 +17,10 @@ ggplot2::autoplot #' @export ggplot2::autolayer +#' @importFrom generics accuracy +#' @export +generics::accuracy + #' @importFrom generics equation #' @export generics::equation diff --git a/man/accuracy.Rd b/man/accuracy.Rd index fa885fe0..a7fe2774 100644 --- a/man/accuracy.Rd +++ b/man/accuracy.Rd @@ -1,24 +1,24 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/accuracy.R -\name{accuracy} -\alias{accuracy} +\name{accuracy.mdl_df} \alias{accuracy.mdl_df} +\alias{accuracy.mdl_ts} \alias{accuracy.fbl_ts} \title{Evaluate accuracy of a forecast or model} \usage{ -accuracy(object, ...) - \method{accuracy}{mdl_df}(object, measures = point_accuracy_measures, ...) +\method{accuracy}{mdl_ts}(object, measures = point_accuracy_measures, ...) + \method{accuracy}{fbl_ts}(object, data, measures = point_accuracy_measures, ..., by = NULL) } \arguments{ \item{object}{A model or forecast object} -\item{...}{Additional arguments to be passed to measures that use it.} - \item{measures}{A list of accuracy measure functions to compute (such as \code{\link{point_accuracy_measures}}, \code{\link{interval_accuracy_measures}}, or \code{\link{distribution_accuracy_measures}})} +\item{...}{Additional arguments to be passed to measures that use it.} + \item{data}{A dataset containing the complete model dataset (both training and test data). The training portion of the data will be used in the computation of some accuracy measures, and the test data is used to compute the forecast errors.} \item{by}{Variables over which the accuracy is computed (useful for computing across forecast horizons in cross-validation). If \code{by} is \code{NULL}, groups will be chosen automatically from the key structure.}