Skip to content

Commit

Permalink
add metric factory print method
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpcouch committed Dec 18, 2023
1 parent 2f75b6c commit 079e427
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ S3method(finalize_estimator_internal,pr_curve)
S3method(finalize_estimator_internal,roc_auc)
S3method(finalize_estimator_internal,roc_curve)
S3method(format,metric)
S3method(format,metric_factory)
S3method(format,metric_set)
S3method(gain_capture,data.frame)
S3method(gain_curve,data.frame)
Expand Down Expand Up @@ -76,6 +77,7 @@ S3method(precision,matrix)
S3method(precision,table)
S3method(print,conf_mat)
S3method(print,metric)
S3method(print,metric_factory)
S3method(print,metric_set)
S3method(recall,data.frame)
S3method(recall,matrix)
Expand Down
14 changes: 14 additions & 0 deletions R/fair-aaa.R
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,20 @@ groupwise_metric_class <- function(fn) {
class(attr(fn, "metrics")[[1]])
}

#' @noRd
#' @export
print.metric_factory <- function(x, ...) {
cat(format(x), sep = "\n")
invisible(x)
}

#' @export
format.metric_factory <- function(x, ...) {
cli::cli_format_method(
cli::cli_text("A {.help [metric factory](yardstick::new_groupwise_metric)}")
)
}

diff_range <- function(x) {
estimates <- x$.estimate

Expand Down

0 comments on commit 079e427

Please sign in to comment.