Skip to content

Commit 9760f87

Browse files
committed
test basic adjust_probability_calibration() usage
1 parent 0797368 commit 9760f87

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

tests/testthat/test-adjust-probability-calibration.R

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,49 @@
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+
147
test_that("adjustment printing", {
248
expect_snapshot(tailor() %>% adjust_probability_calibration("logistic"))
349
})

0 commit comments

Comments
 (0)