-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test basic
adjust_predictions_custom()
usage
- Loading branch information
1 parent
48d9d19
commit 0797368
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | ||
}) |