fit.tailor | R Documentation |
These functions apply fit()
and predict()
methods for each adjustment
added to a tailor, in the order in which they were applied.
## S3 method for class 'tailor'
fit(object, .data, outcome, estimate, probabilities = c(), ...)
## S3 method for class 'tailor'
predict(object, new_data, ...)
object |
A |
.data , new_data |
A data frame containing predictions from a model. |
outcome |
< |
estimate |
< |
probabilities |
< |
... |
Currently ignored. |
An updated tailor()
objects. Any estimates produced and saved by
fit.tailor()
are saved in the adjustments
element of the tailor.
For adjustments that don't require estimating parameters, training with
fit()
simply evaluates tidyselect expressions and logs column names.
For others, as in adjust_numeric_calibration()
, adjustments actually
learn from data; in that case, separate subsets of data ought to be used
for training the tailor and evaluating its performance on predictions.
Note that if .data
has zero or one row, the method
is changed to "none"
.
library(modeldata)
# `predicted` gives hard class predictions based on probability threshold .5
head(two_class_example)
# use a threshold of .1 instead:
tlr <-
tailor() |>
adjust_probability_threshold(.1)
# fit by supplying column names.
tlr_fit <- fit(
tlr,
two_class_example,
outcome = c(truth),
estimate = c(predicted),
probabilities = c(Class1, Class2)
)
# adjust hard class predictions
predict(tlr_fit, two_class_example) |> head()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.