From 0b9a0f4373c21a7e26fc75eb5a0c374fb3df7c68 Mon Sep 17 00:00:00 2001 From: Emil Hvitfeldt Date: Fri, 16 Jan 2026 15:08:47 -0800 Subject: [PATCH] make sure to document all *_metric_summarizer() functions --- R/template.R | 41 ++++++++++++++++++------------------- man/metric-summarizers.Rd | 42 +++++++++++++++++++------------------- vignettes/metric-types.Rmd | 8 ++++++++ 3 files changed, 49 insertions(+), 42 deletions(-) diff --git a/R/template.R b/R/template.R index d63c533c..71322c1a 100644 --- a/R/template.R +++ b/R/template.R @@ -1,25 +1,28 @@ #' Developer function for summarizing new metrics #' -#' `numeric_metric_summarizer()`, `class_metric_summarizer()`, -#' `prob_metric_summarizer()`, `curve_metric_summarizer()`, -#' `dynamic_survival_metric_summarizer()`, -#' `static_survival_metric_summarizer()`, and `quantile_metric_summarizer()` are -#' useful alongside [check_metric] and [yardstick_remove_missing] for -#' implementing new custom metrics. These functions call the metric function -#' inside `dplyr::summarise()` or `dplyr::reframe()` for -#' `curve_metric_summarizer()`. See +#' These functions are useful alongside [check_metric] and +#' [yardstick_remove_missing] for implementing new custom metrics. These +#' functions call the metric function inside `dplyr::summarise()` or +#' `dplyr::reframe()` for `curve_metric_summarizer()`. See #' [Custom performance metrics](https://www.tidymodels.org/learn/develop/metrics/) #' for more information. #' #' @details #' -#' `numeric_metric_summarizer()`, `class_metric_summarizer()`, -#' `prob_metric_summarizer()`, `curve_metric_summarizer()`, -#' `dynamic_survival_metric_summarizer()`, -#' `dynamic_survival_metric_summarizer()`, and `quantile_metric_summarizer()` -#' are generally called from the data frame version of your metric function. It -#' knows how to call your metric over grouped data frames and returns a `tibble` -#' consistent with other metrics. +#' The following functions are generally called from the data frame version of +#' your metric function. They know how to call your metric over grouped data +#' frames and return a `tibble` consistent with other metrics. +#' +#' - `numeric_metric_summarizer()` +#' - `class_metric_summarizer()` +#' - `prob_metric_summarizer()` +#' - `ordered_prob_metric_summarizer()` +#' - `curve_metric_summarizer()` +#' - `dynamic_survival_metric_summarizer()` +#' - `static_survival_metric_summarizer()` +#' - `curve_survival_metric_summarizer()` +#' - `linear_pred_survival_metric_summarizer()` +#' - `quantile_metric_summarizer()` #' #' @inheritParams rlang::args_dots_empty #' @inheritParams rlang::args_error_context @@ -33,12 +36,8 @@ #' needed to calculate the metric. #' #' @param data The data frame with `truth` and `estimate` columns passed in from -#' the data frame version of your metric function that called -#' `numeric_metric_summarizer()`, `class_metric_summarizer()`, -#' `prob_metric_summarizer()`, `curve_metric_summarizer()`, -#' `dynamic_survival_metric_summarizer()`, -#' `static_survival_metric_summarizer()`, or -#' `quantile_metric_summarizer()`. +#' the data frame version of your metric function that called the metric +#' summarizer. #' #' @param truth The unquoted column name corresponding to the `truth` column. #' diff --git a/man/metric-summarizers.Rd b/man/metric-summarizers.Rd index ea513087..002ac03b 100644 --- a/man/metric-summarizers.Rd +++ b/man/metric-summarizers.Rd @@ -157,12 +157,8 @@ generally takes \code{truth}, \code{estimate}, \code{na_rm}, and any other extra needed to calculate the metric.} \item{data}{The data frame with \code{truth} and \code{estimate} columns passed in from -the data frame version of your metric function that called -\code{numeric_metric_summarizer()}, \code{class_metric_summarizer()}, -\code{prob_metric_summarizer()}, \code{curve_metric_summarizer()}, -\code{dynamic_survival_metric_summarizer()}, -\code{static_survival_metric_summarizer()}, or -\code{quantile_metric_summarizer()}.} +the data frame version of your metric function that called the metric +summarizer.} \item{truth}{The unquoted column name corresponding to the \code{truth} column.} @@ -199,25 +195,29 @@ value of the \code{fn} or a single string of either \code{"first"} or \code{"sec to pass along describing which level should be considered the "event".} } \description{ -\code{numeric_metric_summarizer()}, \code{class_metric_summarizer()}, -\code{prob_metric_summarizer()}, \code{curve_metric_summarizer()}, -\code{dynamic_survival_metric_summarizer()}, -\code{static_survival_metric_summarizer()}, and \code{quantile_metric_summarizer()} are -useful alongside \link{check_metric} and \link{yardstick_remove_missing} for -implementing new custom metrics. These functions call the metric function -inside \code{dplyr::summarise()} or \code{dplyr::reframe()} for -\code{curve_metric_summarizer()}. See +These functions are useful alongside \link{check_metric} and +\link{yardstick_remove_missing} for implementing new custom metrics. These +functions call the metric function inside \code{dplyr::summarise()} or +\code{dplyr::reframe()} for \code{curve_metric_summarizer()}. See \href{https://www.tidymodels.org/learn/develop/metrics/}{Custom performance metrics} for more information. } \details{ -\code{numeric_metric_summarizer()}, \code{class_metric_summarizer()}, -\code{prob_metric_summarizer()}, \code{curve_metric_summarizer()}, -\code{dynamic_survival_metric_summarizer()}, -\code{dynamic_survival_metric_summarizer()}, and \code{quantile_metric_summarizer()} -are generally called from the data frame version of your metric function. It -knows how to call your metric over grouped data frames and returns a \code{tibble} -consistent with other metrics. +The following functions are generally called from the data frame version of +your metric function. They know how to call your metric over grouped data +frames and return a \code{tibble} consistent with other metrics. +\itemize{ +\item \code{numeric_metric_summarizer()} +\item \code{class_metric_summarizer()} +\item \code{prob_metric_summarizer()} +\item \code{ordered_prob_metric_summarizer()} +\item \code{curve_metric_summarizer()} +\item \code{dynamic_survival_metric_summarizer()} +\item \code{static_survival_metric_summarizer()} +\item \code{curve_survival_metric_summarizer()} +\item \code{linear_pred_survival_metric_summarizer()} +\item \code{quantile_metric_summarizer()} +} } \seealso{ \link{check_metric} \link{yardstick_remove_missing} \code{\link[=finalize_estimator]{finalize_estimator()}} \code{\link[=dots_to_estimate]{dots_to_estimate()}} diff --git a/vignettes/metric-types.Rmd b/vignettes/metric-types.Rmd index fb589faa..51678a9d 100644 --- a/vignettes/metric-types.Rmd +++ b/vignettes/metric-types.Rmd @@ -160,10 +160,18 @@ all_metrics <- bind_rows( type = "dynamic survival", metric = get_metrics(fns, "dynamic_survival_metric") ), + tibble( + type = "integrated survival", + metric = get_metrics(fns, "integrated_survival_metric") + ), tibble( type = "static survival", metric = get_metrics(fns, "static_survival_metric") ), + tibble( + type = "linear predictor survival", + metric = get_metrics(fns, "linear_pred_survival_metric") + ), tibble( type = "quantile", metric = get_metrics(fns, "quantile_metric")