adjust_predictions_custom: Change or add variables

View source: R/adjust-predictions-custom.R

adjust_predictions_customR Documentation

Change or add variables

Description

This adjustment functions allows for arbitrary transformations of model predictions using dplyr::mutate() statements.

Usage

adjust_predictions_custom(x, ..., .pkgs = character(0))

Arguments

x

A tailor().

...

Name-value pairs of expressions. See dplyr::mutate().

.pkgs

A character string of extra packages that are needed to execute the commands.

Value

An updated tailor() containing the new operation.

Data-dependent transformations

Note that custom adjustments should not carry out estimation. If they do, the estimation steps will be carried out independently at fit() and predict() time. For example, if your transformation includes a mean shift, the postprocessor will take the mean of the column supplied in the training data at fit() and, rather than reusing that mean at predict() will take the mean again of the dataset supplied at predict() time.

Data Usage

This adjustment doesn't require estimation and, as such, the same data that's used to train it with fit() can be predicted on with predict(); fitting this adjustment just collects metadata on the supplied column names and does not risk data leakage.

Examples


library(modeldata)

head(two_class_example)

tlr <-
  tailor() |>
  adjust_equivocal_zone() |>
  adjust_predictions_custom(linear_predictor = binomial()$linkfun(Class2))

tlr_fit <- fit(
  tlr,
  two_class_example,
  outcome = c(truth),
  estimate = c(predicted),
  probabilities = c(Class1, Class2)
)

predict(tlr_fit, two_class_example) |> head()


tailor documentation built on Aug. 25, 2025, 9:50 a.m.