Skip to content

Commit

Permalink
test basic adjust_predictions_custom() usage
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpcouch committed Sep 16, 2024
1 parent 48d9d19 commit 0797368
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/testthat/test-adjust-predictions-custom.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
test_that("basic adjust_predictions_custom() usage works", {
skip_if_not_installed("modeldata")
library(modeldata)

# fitting and predicting happens without raising conditions
expect_no_condition(
tlr <-
tailor() %>%
adjust_predictions_custom(linear_predictor = binomial()$linkfun(Class2))
)

expect_no_condition(
tlr_fit <- fit(
tlr,
two_class_example,
outcome = c(truth),
estimate = c(predicted),
probabilities = c(Class1, Class2)
)
)
expect_no_condition(
tlr_pred <- predict(tlr_fit, two_class_example)
)

# classes are as expected
expect_s3_class(tlr, "tailor")
expect_s3_class(tlr_fit, "tailor")
expect_s3_class(tlr_pred, "tbl_df")

# column names are as expected
expect_equal(
c(colnames(two_class_example), "linear_predictor"),
colnames(tlr_pred)
)

# calculations match those done manually
expect_equal(
tlr_pred$linear_predictor,
binomial()$linkfun(two_class_example$Class2)
)
})

test_that("adjustment printing", {
expect_snapshot(tailor() %>% adjust_predictions_custom())
})

0 comments on commit 0797368

Please sign in to comment.