multi_predict.nested_model_fit {nestedmodels}R Documentation

Nested model predictions across many sub-models

Description

parsnip::multi_predict() method for nested models. Allows predictions to be made on sub-models in a model object.

Usage

## S3 method for class 'nested_model_fit'
multi_predict(object, new_data, ...)

Arguments

object

A nested_model_fit object produced by fit.nested_model().

new_data

A data frame - can be nested or non-nested.

...

Passed onto parsnip::multi_predict()

Value

A tibble with the same number of rows as new_data, after it has been unnested.

See Also

parsnip::multi_predict()

Examples



library(dplyr)
library(tidyr)
library(parsnip)
library(glmnet)

data <- filter(example_nested_data, id %in% 16:20)

nested_data <- nest(data, data = -id2)

model <- linear_reg(penalty = 1) %>%
  set_engine("glmnet") %>%
  nested()

fitted <- fit(model, z ~ x + y + a + b, nested_data)

multi_predict(fitted, example_nested_data,
  penalty = c(0.1, 0.2, 0.3)
)


[Package nestedmodels version 1.1.0 Index]