diff --git a/R/adjust-probability-calibration.R b/R/adjust-probability-calibration.R index 6b7e16c..089399b 100644 --- a/R/adjust-probability-calibration.R +++ b/R/adjust-probability-calibration.R @@ -15,7 +15,6 @@ #' #' @inheritSection adjust_numeric_calibration Data Usage #' -# TODO: see #36 #' @examplesIf FALSE # @examplesIf rlang::is_installed("modeldata") #' library(modeldata) @@ -95,10 +94,10 @@ fit.probability_calibration <- function(object, data, tailor = NULL, ...) { eval_bare( call2( paste0("cal_estimate_", method), - .data = data, + .data = expr(data), # todo: make getters for the entries in `columns` truth = tailor$columns$outcome, - estimate = tailor$columns$estimate, + estimate = tailor$columns$probabilities, .ns = "probably" ) ) @@ -116,7 +115,11 @@ fit.probability_calibration <- function(object, data, tailor = NULL, ...) { #' @export predict.probability_calibration <- function(object, new_data, tailor, ...) { - probably::cal_apply(new_data, object$results$fit) + probably::cal_apply( + .data = new_data, + object = object$results$fit, + pred_class = !!tailor$columns$estimate + ) } # todo probably needs required_pkgs methods for cal objects diff --git a/tests/testthat/test-adjust-probability-calibration.R b/tests/testthat/test-adjust-probability-calibration.R index 5caafd3..5704466 100644 --- a/tests/testthat/test-adjust-probability-calibration.R +++ b/tests/testthat/test-adjust-probability-calibration.R @@ -15,8 +15,6 @@ test_that("basic adjust_probability_calibration() usage works", { adjust_probability_calibration(method = "logistic") ) - skip("TODO: cannot run for now due to #36") - expect_no_condition( tlr_fit <- fit( tlr, @@ -28,7 +26,7 @@ test_that("basic adjust_probability_calibration() usage works", { ) expect_no_condition( - predict(tlr_fit, d_test) + tlr_pred <- predict(tlr_fit, d_test) ) # classes are as expected diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 722f262..81df024 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -17,7 +17,7 @@ test_that("tailor_fully_trained works", { fit( two_class_example, outcome = "truth", - estimate = tidyselect::contains("Class"), + estimate = predicted, probabilities = tidyselect::contains("Class") ) %>% adjust_probability_threshold(.5) @@ -31,10 +31,7 @@ test_that("tailor_fully_trained works", { fit( two_class_example, outcome = "truth", - # todo: this function requires a different format of `estimate` - # and `probabilities` specification than the call below to - # be able to fit properly. - estimate = tidyselect::contains("Class"), + estimate = predicted, probabilities = tidyselect::contains("Class") ) )