Skip to contents

Take in a learner, and return a learner that produces predictor functions which are truncated to the (min, max) region (boundary inclusive).

Usage

truncate_lnr(lnr, min, max)

Arguments

lnr

a nadir learner

min

the numeric minimum scalar value defining the minimum that can be predicted; Could be -Inf

max

the numeric maximum scalar value defining the maximum that can be predicted; Can be Inf

Value

A learner that produces predictor functions which trim their own output before returning

Examples

lnr_truncated <- truncate_lnr(lnr_glm, min = 20, max = 22)
head(lnr_glm(mtcars, mpg ~ cyl + am + hp)(mtcars))
#>         Mazda RX4     Mazda RX4 Wag        Datsun 710    Hornet 4 Drive 
#>          23.97302          23.97302          26.85433          20.06874 
#> Hornet Sportabout           Valiant 
#>          15.41740          20.25312 
head(lnr_truncated(mtcars, mpg ~ cyl + am + hp)(mtcars))
#>         Mazda RX4     Mazda RX4 Wag        Datsun 710    Hornet 4 Drive 
#>          22.00000          22.00000          22.00000          20.06874 
#> Hornet Sportabout           Valiant 
#>          20.00000          20.25312