|
| 1 | +test_that("basic adjust_probability_calibration() usage works", { |
| 2 | + skip_if_not_installed("modeldata") |
| 3 | + library(modeldata) |
| 4 | + |
| 5 | + # split example data |
| 6 | + set.seed(1) |
| 7 | + in_rows <- sample(c(TRUE, FALSE), nrow(two_class_example), replace = TRUE) |
| 8 | + d_potato <- two_class_example[in_rows, ] |
| 9 | + d_test <- two_class_example[!in_rows, ] |
| 10 | + |
| 11 | + # fitting and predicting happens without raising conditions |
| 12 | + expect_no_condition( |
| 13 | + tlr <- |
| 14 | + tailor() %>% |
| 15 | + adjust_probability_calibration(method = "logistic") |
| 16 | + ) |
| 17 | + |
| 18 | + skip("TODO: cannot run for now due to #36") |
| 19 | + |
| 20 | + expect_no_condition( |
| 21 | + tlr_fit <- fit( |
| 22 | + tlr, |
| 23 | + d_potato, |
| 24 | + outcome = c(truth), |
| 25 | + estimate = c(predicted), |
| 26 | + probabilities = c(Class1, Class2) |
| 27 | + ) |
| 28 | + ) |
| 29 | + |
| 30 | + expect_no_condition( |
| 31 | + predict(tlr_fit, d_test) |
| 32 | + ) |
| 33 | + |
| 34 | + # classes are as expected |
| 35 | + expect_s3_class(tlr, "tailor") |
| 36 | + expect_s3_class(tlr_fit, "tailor") |
| 37 | + expect_s3_class(tlr_pred, "tbl_df") |
| 38 | + |
| 39 | + # column names are as expected |
| 40 | + expect_equal(colnames(d_test), colnames(tlr_pred)) |
| 41 | + |
| 42 | + # calculations match those done manually |
| 43 | + # TODO: write out the manual code with probably |
| 44 | +}) |
| 45 | + |
| 46 | + |
1 | 47 | test_that("adjustment printing", {
|
2 | 48 | expect_snapshot(tailor() %>% adjust_probability_calibration("logistic"))
|
3 | 49 | })
|
|
0 commit comments