19
19
# ' with the [tidymodels](https://tidymodels.org) framework; for greatest ease
20
20
# ' of use, situate tailors in model workflows with `?workflows::add_tailor()`.
21
21
# '
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()`.
25
22
# ' @param outcome <[`tidy-select`][dplyr::dplyr_tidy_select]> Only required
26
23
# ' when used independently of `?workflows::add_tailor()`, and can also be passed
27
24
# ' at `fit()` time instead. The column name of the outcome variable.
64
61
# ' # adjust hard class predictions
65
62
# ' predict(tlr_fit, two_class_example) %>% count(predicted)
66
63
# ' @export
67
- tailor <- function (type = " unknown" , outcome = NULL , estimate = NULL ,
68
- probabilities = NULL ) {
64
+ tailor <- function (outcome = NULL , estimate = NULL , probabilities = NULL ) {
69
65
columns <-
70
66
list (
71
67
outcome = outcome ,
72
- type = type ,
73
68
estimate = estimate ,
74
69
probabilities = probabilities
75
70
)
76
71
77
72
new_tailor(
78
- type ,
73
+ " unknown " ,
79
74
adjustments = list (),
80
75
columns = columns ,
81
76
ptype = tibble :: new_tibble(list ()),
@@ -84,8 +79,6 @@ tailor <- function(type = "unknown", outcome = NULL, estimate = NULL,
84
79
}
85
80
86
81
new_tailor <- function (type , adjustments , columns , ptype , call ) {
87
- type <- arg_match0(type , c(" unknown" , " regression" , " binary" , " multiclass" ))
88
-
89
82
if (! is.list(adjustments )) {
90
83
cli_abort(" The {.arg adjustments} argument should be a list." , call = call )
91
84
}
@@ -97,8 +90,14 @@ new_tailor <- function(type, adjustments, columns, ptype, call) {
97
90
{.val adjustment}: {bad_adjustment}." , call = call )
98
91
}
99
92
93
+ orderings <- adjustment_orderings(adjustments )
94
+
95
+ if (type == " unknown" ) {
96
+ type <- infer_type(orderings )
97
+ }
98
+
100
99
# validate adjustment order and check duplicates
101
- validate_order(adjustments , type , call )
100
+ validate_order(orderings , type , call )
102
101
103
102
# check columns
104
103
res <- list (
@@ -233,5 +232,5 @@ set_tailor_type <- function(object, y) {
233
232
# todo setup eval_time
234
233
# todo missing methods:
235
234
# todo tune_args
236
- # todo tidy
235
+ # todo tidy (this should probably just be `adjustment_orderings()`)
237
236
# todo extract_parameter_set_dials
0 commit comments