Skip to content

Commit

Permalink
Fix inconsistent appearance of distance metric in threshold_perf()
Browse files Browse the repository at this point in the history
…with custom metric sets

Fixes #149 - Updated `threshold_perf()` to use the correct metric names ("sensitivity" and "specificity") instead of the outdated names ("sens" and "spec").
  • Loading branch information
jrwinget committed Aug 15, 2024
1 parent 48dec58 commit 4cd3800
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

* Fixed an error in `int_conformal_cv()` when grouped resampling was used (#141).

* Fixed an issue where the `distance` metric appeared inconsistently when using `threshold_perf()` with custom metric sets (#149).

# probably 1.0.3

Expand Down
8 changes: 5 additions & 3 deletions R/threshold_perf.R
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,11 @@ threshold_perf.data.frame <- function(.data,
# Create the `distance` metric data frame
# and add it on
sens_vec <- .data_metrics %>%
dplyr::filter(.metric == "sens") %>%
dplyr::filter(.metric == "sensitivity") %>%
dplyr::pull(.estimate)

dist <- .data_metrics %>%
dplyr::filter(.metric == "spec") %>%
dplyr::filter(.metric == "specificity") %>%
dplyr::mutate(
.metric = "distance",
# .estimate is specificity currently. This recodes as distance
Expand Down Expand Up @@ -232,7 +232,9 @@ expand_preds <- function(.data, threshold, inc = NULL) {
check_thresholded_metrics <- function(x) {
y <- dplyr::as_tibble(x)
if (!all(y$class == "class_metric")) {
rlang::abort("All metrics must be of type 'class_metric' (e.g. `sensitivity()`, ect)")
rlang::abort(
"All metrics must be of type 'class_metric' (e.g. `sensitivity()`, ect)"
)
}
# check to see if sensitivity and specificity are in the lists
has_sens <-
Expand Down

0 comments on commit 4cd3800

Please sign in to comment.