Skip to content

Commit 0797368

Browse files
committed
test basic adjust_predictions_custom() usage
1 parent 48d9d19 commit 0797368

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,45 @@
1+
test_that("basic adjust_predictions_custom() usage works", {
2+
skip_if_not_installed("modeldata")
3+
library(modeldata)
4+
5+
# fitting and predicting happens without raising conditions
6+
expect_no_condition(
7+
tlr <-
8+
tailor() %>%
9+
adjust_predictions_custom(linear_predictor = binomial()$linkfun(Class2))
10+
)
11+
12+
expect_no_condition(
13+
tlr_fit <- fit(
14+
tlr,
15+
two_class_example,
16+
outcome = c(truth),
17+
estimate = c(predicted),
18+
probabilities = c(Class1, Class2)
19+
)
20+
)
21+
expect_no_condition(
22+
tlr_pred <- predict(tlr_fit, two_class_example)
23+
)
24+
25+
# classes are as expected
26+
expect_s3_class(tlr, "tailor")
27+
expect_s3_class(tlr_fit, "tailor")
28+
expect_s3_class(tlr_pred, "tbl_df")
29+
30+
# column names are as expected
31+
expect_equal(
32+
c(colnames(two_class_example), "linear_predictor"),
33+
colnames(tlr_pred)
34+
)
35+
36+
# calculations match those done manually
37+
expect_equal(
38+
tlr_pred$linear_predictor,
39+
binomial()$linkfun(two_class_example$Class2)
40+
)
41+
})
42+
143
test_that("adjustment printing", {
244
expect_snapshot(tailor() %>% adjust_predictions_custom())
345
})

0 commit comments

Comments
 (0)