Truncating ranges involves limiting the output of a model to a specific range of values, typically to avoid extreme or unrealistic predictions. This technique can help improve the practical applicability of a model's outputs by constraining them within reasonable bounds based on domain knowledge or physical limitations.
Arguments
- x
A
tailor()
.- upper_limit, lower_limit
A numeric value, NA (for no truncation) or
hardhat::tune()
.
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
if (FALSE) {
library(tibble)
# create example data
set.seed(1)
d <- tibble(y = rnorm(100), y_pred = y/2 + rnorm(100))
d
# specify calibration
tlr <-
tailor() %>%
adjust_numeric_range(lower_limit = 1)
# train tailor by passing column names. situate in a modeling workflow with
# `workflows::add_tailor()` to avoid having to specify column names manually
tlr_fit <- fit(tlr, d, outcome = y, estimate = y_pred)
predict(tlr_fit, d)
}