View source: R/adjust-numeric-range.R
adjust_numeric_range | R Documentation |
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.
adjust_numeric_range(x, lower_limit = -Inf, upper_limit = Inf)
x |
A |
upper_limit , lower_limit |
A numeric value, NA (for no truncation) or
|
An updated tailor()
containing the new operation.
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.
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.
tlr_fit <- fit(tlr, d, outcome = y, estimate = y_pred)
predict(tlr_fit, d)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.