Skip to content

Commit

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

# split example data
set.seed(1)
in_rows <- sample(c(TRUE, FALSE), nrow(two_class_example), replace = TRUE)
d_potato <- two_class_example[in_rows, ]
d_test <- two_class_example[!in_rows, ]

# fitting and predicting happens without raising conditions
expect_no_condition(
tlr <-
tailor() %>%
adjust_probability_calibration(method = "logistic")
)

skip("TODO: cannot run for now due to #36")

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

expect_no_condition(
predict(tlr_fit, d_test)
)

# 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(colnames(d_test), colnames(tlr_pred))

# calculations match those done manually
# TODO: write out the manual code with probably
})


test_that("adjustment printing", {
expect_snapshot(tailor() %>% adjust_probability_calibration("logistic"))
})
Expand Down

0 comments on commit 9760f87

Please sign in to comment.