View source: R/multi_predict.R
multi_predict.nested_model_fit | R Documentation |
parsnip::multi_predict()
method for nested models. Allows predictions
to be made on sub-models in a model object.
## S3 method for class 'nested_model_fit'
multi_predict(object, new_data, ...)
object |
A |
new_data |
A data frame - can be nested or non-nested. |
... |
Passed onto |
A tibble with the same number of rows as new_data
, after it
has been unnested.
parsnip::multi_predict()
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)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.