The predict()
function computes predictions from each of the
models in the ensembles and returns a single aggregated value
for each sample in new_data
.
Usage
# S3 method for bagger
predict(object, new_data, type = NULL, ...)
Arguments
- object
An object generated by
bagger()
.- new_data
A data frame of predictors. If a recipe or formula were originally used, the original data should be passed here instead of a preprocessed version.
- type
A single character value for the type of predictions. For regression models,
type = 'numeric'
is valid and'class'
and'prob'
are valid for classification models.- ...
Not currently used.
Examples
data(airquality)
set.seed(7687)
mars_bag <- bagger(Ozone ~ ., data = airquality, base_model = "MARS", times = 5)
predict(mars_bag, new_data = airquality[, -1])
#> # A tibble: 153 × 1
#> .pred
#> <dbl>
#> 1 38.6
#> 2 19.8
#> 3 15.8
#> 4 18.5
#> 5 NaN
#> 6 NaN
#> 7 25.2
#> 8 14.4
#> 9 12.4
#> 10 31.0
#> # ℹ 143 more rows