File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ test_that(" basic adjust_probability_threshold() 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_probability_threshold(.1 )
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
+
22
+ expect_no_condition(
23
+ tlr_pred <- predict(tlr_fit , two_class_example )
24
+ )
25
+
26
+ # classes are as expected
27
+ expect_s3_class(tlr , " tailor" )
28
+ expect_s3_class(tlr_fit , " tailor" )
29
+ expect_s3_class(tlr_pred , " tbl_df" )
30
+
31
+ # column names are as expected
32
+ expect_equal(colnames(two_class_example ), colnames(tlr_pred ))
33
+
34
+ # calculations match those done manually
35
+ manual_pred <- factor (ifelse(two_class_example $ Class1 > .1 , " Class1" , " Class2" ))
36
+ expect_equal(tlr_pred $ predicted , manual_pred )
37
+ })
38
+
1
39
test_that(" adjustment printing" , {
2
40
expect_snapshot(tailor() %> % adjust_probability_threshold())
3
41
expect_snapshot(tailor() %> % adjust_probability_threshold(hardhat :: tune()))
You can’t perform that action at this time.
0 commit comments