File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
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
+
1
43
test_that(" adjustment printing" , {
2
44
expect_snapshot(tailor() %> % adjust_predictions_custom())
3
45
})
You can’t perform that action at this time.
0 commit comments