
Prediction filter bounding predictions to the observed response range
Source:R/predict_filter.R
predict_filter_bound_dynamic.RdGenerates a prediction filter for the predict.filter
argument of learner that bounds predictions to the range of the
response observed in the estimation data (min(response), max(response)).
Value
A filter generator function (see learner).
Examples
data(cars)
lr <- learner_glm(
speed ~ dist,
learner.args = list(
predict.filter = predict_filter_bound_dynamic(
upper = TRUE, response = "speed"
)
)
)
lr$estimate(cars)
lr$predict(data.frame(dist = c(200, 2000)))
#> 1 2
#> 25 25