Skip to content

Commit a3f5170

Browse files
committed
remove tailor(type)
doesn't yet check for compatibility between adjustments pre-fit
1 parent 6704eb6 commit a3f5170

10 files changed

+30
-64
lines changed

R/tailor.R

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
#' with the [tidymodels](https://tidymodels.org) framework; for greatest ease
2020
#' of use, situate tailors in model workflows with `?workflows::add_tailor()`.
2121
#'
22-
#' @param type Character. The model sub-mode. Possible values are
23-
#' `"unknown"`, `"regression"`, `"binary"`, or `"multiclass"`. Only required
24-
#' when used independently of `?workflows::add_tailor()`.
2522
#' @param outcome <[`tidy-select`][dplyr::dplyr_tidy_select]> Only required
2623
#' when used independently of `?workflows::add_tailor()`, and can also be passed
2724
#' at `fit()` time instead. The column name of the outcome variable.
@@ -64,18 +61,16 @@
6461
#' # adjust hard class predictions
6562
#' predict(tlr_fit, two_class_example) %>% count(predicted)
6663
#' @export
67-
tailor <- function(type = "unknown", outcome = NULL, estimate = NULL,
68-
probabilities = NULL) {
64+
tailor <- function(outcome = NULL, estimate = NULL, probabilities = NULL) {
6965
columns <-
7066
list(
7167
outcome = outcome,
72-
type = type,
7368
estimate = estimate,
7469
probabilities = probabilities
7570
)
7671

7772
new_tailor(
78-
type,
73+
"unknown",
7974
adjustments = list(),
8075
columns = columns,
8176
ptype = tibble::new_tibble(list()),

man/tailor.Rd

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/_snaps/adjust-numeric-calibration.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,7 @@
2020
---
2121

2222
Code
23-
tailor("binary") %>% adjust_numeric_calibration("linear")
24-
Condition
25-
Error in `adjust_numeric_calibration()`:
26-
! A binary tailor is incompatible with the adjustment `adjust_numeric_calibration()`.
27-
28-
---
29-
30-
Code
31-
tailor("regression") %>% adjust_numeric_calibration("binary")
23+
tailor() %>% adjust_numeric_calibration("binary")
3224
Condition
3325
Error in `adjust_numeric_calibration()`:
3426
! `method` must be one of "linear", "isotonic", or "isotonic_boot", not "binary".

tests/testthat/_snaps/adjust-probability-calibration.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,7 @@
2020
---
2121

2222
Code
23-
tailor("regression") %>% adjust_probability_calibration("binary")
24-
Condition
25-
Error in `adjust_probability_calibration()`:
26-
! A regression tailor is incompatible with the adjustment `adjust_probability_calibration()`.
27-
28-
---
29-
30-
Code
31-
tailor("binary") %>% adjust_probability_calibration("linear")
23+
tailor() %>% adjust_probability_calibration("linear")
3224
Condition
3325
Error in `adjust_probability_calibration()`:
3426
! `method` must be one of "logistic", "multinomial", "beta", "isotonic", or "isotonic_boot", not "linear".

tests/testthat/_snaps/tailor.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,31 @@
1010
---
1111

1212
Code
13-
tailor(type = "binary")
13+
tailor()
1414
Message
1515
1616
-- tailor ----------------------------------------------------------------------
17-
A binary postprocessor with 0 adjustments.
17+
A postprocessor with 0 adjustments.
1818

1919
---
2020

2121
Code
22-
tailor(type = "binary") %>% adjust_probability_threshold(0.2)
22+
tailor() %>% adjust_probability_threshold(0.2)
2323
Message
2424
2525
-- tailor ----------------------------------------------------------------------
26-
A binary postprocessor with 1 adjustment:
26+
A postprocessor with 1 adjustment:
2727
2828
* Adjust probability threshold to 0.2.
2929

3030
---
3131

3232
Code
33-
tailor(type = "binary") %>% adjust_probability_threshold(0.2) %>%
34-
adjust_equivocal_zone()
33+
tailor() %>% adjust_probability_threshold(0.2) %>% adjust_equivocal_zone()
3534
Message
3635
3736
-- tailor ----------------------------------------------------------------------
38-
A binary postprocessor with 2 adjustments:
37+
A postprocessor with 2 adjustments:
3938
4039
* Adjust probability threshold to 0.2.
4140
* Add equivocal zone of size 0.1.

tests/testthat/_snaps/validation-rules.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# validation of adjustments (regression)
22

33
Code
4-
tailor(type = "regression") %>% adjust_numeric_range(lower_limit = 2) %>%
4+
tailor() %>% adjust_numeric_range(lower_limit = 2) %>%
55
adjust_numeric_calibration() %>% adjust_predictions_custom(squared = .pred^2)
66
Condition
77
Error in `adjust_numeric_calibration()`:
@@ -10,7 +10,7 @@
1010
# validation of adjustments (classification)
1111

1212
Code
13-
tailor(type = "binary") %>% adjust_probability_threshold(threshold = 0.4) %>%
13+
tailor() %>% adjust_probability_threshold(threshold = 0.4) %>%
1414
adjust_probability_calibration()
1515
Condition
1616
Error in `adjust_probability_calibration()`:
@@ -28,7 +28,7 @@
2828
---
2929

3030
Code
31-
tailor(type = "binary") %>% adjust_predictions_custom(veg = "potato") %>%
31+
tailor() %>% adjust_predictions_custom(veg = "potato") %>%
3232
adjust_probability_threshold(threshold = 0.4) %>%
3333
adjust_probability_calibration()
3434
Condition
@@ -48,7 +48,7 @@
4848
---
4949

5050
Code
51-
tailor(type = "binary") %>% adjust_predictions_custom(veg = "potato") %>%
51+
tailor() %>% adjust_predictions_custom(veg = "potato") %>%
5252
adjust_probability_threshold(threshold = 0.4) %>%
5353
adjust_probability_threshold(threshold = 0.5) %>%
5454
adjust_probability_calibration()
@@ -70,7 +70,7 @@
7070
---
7171

7272
Code
73-
tailor(type = "binary") %>% adjust_equivocal_zone(value = 0.2) %>%
73+
tailor() %>% adjust_equivocal_zone(value = 0.2) %>%
7474
adjust_probability_threshold(threshold = 0.4)
7575
Condition
7676
Error in `adjust_probability_threshold()`:

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,7 @@ test_that("errors informatively with bad input", {
4444
expect_snapshot(error = TRUE, adjust_numeric_calibration(tailor(), "boop"))
4545
expect_snapshot(
4646
error = TRUE,
47-
tailor("binary") %>% adjust_numeric_calibration("linear")
48-
)
49-
expect_snapshot(
50-
error = TRUE,
51-
tailor("regression") %>% adjust_numeric_calibration("binary")
47+
tailor() %>% adjust_numeric_calibration("binary")
5248
)
5349

5450
expect_no_condition(adjust_numeric_calibration(tailor()))

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,7 @@ test_that("errors informatively with bad input", {
5454
expect_snapshot(error = TRUE, adjust_probability_calibration(tailor(), "boop"))
5555
expect_snapshot(
5656
error = TRUE,
57-
tailor("regression") %>% adjust_probability_calibration("binary")
58-
)
59-
expect_snapshot(
60-
error = TRUE,
61-
tailor("binary") %>% adjust_probability_calibration("linear")
57+
tailor() %>% adjust_probability_calibration("linear")
6258
)
6359

6460
expect_no_condition(adjust_numeric_calibration(tailor()))

tests/testthat/test-tailor.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
test_that("tailor printing", {
22
expect_snapshot(tailor())
3-
expect_snapshot(tailor(type = "binary"))
3+
expect_snapshot(tailor())
44
expect_snapshot(
5-
tailor(type = "binary") %>%
5+
tailor() %>%
66
adjust_probability_threshold(.2)
77
)
88
expect_snapshot(
9-
tailor(type = "binary") %>%
9+
tailor() %>%
1010
adjust_probability_threshold(.2) %>%
1111
adjust_equivocal_zone()
1212
)

tests/testthat/test-validation-rules.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
test_that("validation of adjustments (regression)", {
22
expect_no_condition(
33
reg_tailor <-
4-
tailor(type = "regression") %>%
4+
tailor() %>%
55
adjust_numeric_calibration() %>%
66
adjust_numeric_range(lower_limit = 2) %>%
77
adjust_predictions_custom(squared = .pred^2)
88
)
99

1010
expect_snapshot(
1111
error = TRUE,
12-
tailor(type = "regression") %>%
12+
tailor() %>%
1313
adjust_numeric_range(lower_limit = 2) %>%
1414
adjust_numeric_calibration() %>%
1515
adjust_predictions_custom(squared = .pred^2)
@@ -19,7 +19,7 @@ test_that("validation of adjustments (regression)", {
1919
# modifies the prediction?
2020
expect_no_condition(
2121
reg_tailor <-
22-
tailor(type = "regression") %>%
22+
tailor() %>%
2323
adjust_predictions_custom(squared = .pred^2) %>%
2424
adjust_numeric_calibration() %>%
2525
adjust_numeric_range(lower_limit = 2)
@@ -29,14 +29,14 @@ test_that("validation of adjustments (regression)", {
2929
test_that("validation of adjustments (classification)", {
3030
expect_no_condition(
3131
cls_tailor_1 <-
32-
tailor(type = "binary") %>%
32+
tailor() %>%
3333
adjust_probability_calibration("logistic") %>%
3434
adjust_probability_threshold(threshold = .4)
3535
)
3636

3737
expect_no_condition(
3838
cls_tailor_2 <-
39-
tailor(type = "binary") %>%
39+
tailor() %>%
4040
adjust_predictions_custom(starch = "potato") %>%
4141
adjust_predictions_custom(veg = "green beans") %>%
4242
adjust_probability_calibration("logistic") %>%
@@ -45,7 +45,7 @@ test_that("validation of adjustments (classification)", {
4545

4646
expect_snapshot(
4747
error = TRUE,
48-
tailor(type = "binary") %>%
48+
tailor() %>%
4949
adjust_probability_threshold(threshold = .4) %>%
5050
adjust_probability_calibration()
5151
)
@@ -59,7 +59,7 @@ test_that("validation of adjustments (classification)", {
5959

6060
expect_snapshot(
6161
error = TRUE,
62-
tailor(type = "binary") %>%
62+
tailor() %>%
6363
adjust_predictions_custom(veg = "potato") %>%
6464
adjust_probability_threshold(threshold = .4) %>%
6565
adjust_probability_calibration()
@@ -75,7 +75,7 @@ test_that("validation of adjustments (classification)", {
7575

7676
expect_snapshot(
7777
error = TRUE,
78-
tailor(type = "binary") %>%
78+
tailor() %>%
7979
adjust_predictions_custom(veg = "potato") %>%
8080
adjust_probability_threshold(threshold = .4) %>%
8181
adjust_probability_threshold(threshold = .5) %>%
@@ -93,7 +93,7 @@ test_that("validation of adjustments (classification)", {
9393

9494
expect_snapshot(
9595
error = TRUE,
96-
tailor(type = "binary") %>%
96+
tailor() %>%
9797
adjust_equivocal_zone(value = .2) %>%
9898
adjust_probability_threshold(threshold = .4)
9999
)

0 commit comments

Comments
 (0)