Skip to content

Commit

Permalink
Use generics::accuracy()
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchelloharawild committed Jul 5, 2023
1 parent e09af0c commit 35eeca5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 3 additions & 9 deletions R/accuracy.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)){
Expand All @@ -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(...)
Expand Down
4 changes: 4 additions & 0 deletions R/reexports.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ ggplot2::autoplot
#' @export
ggplot2::autolayer

#' @importFrom generics accuracy
#' @export
generics::accuracy

#' @importFrom generics equation
#' @export
generics::equation
Expand Down
12 changes: 6 additions & 6 deletions man/accuracy.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 35eeca5

Please sign in to comment.