Skip to contents

Safely Make predictions on a fitted workflow from a model spec tibble.

Usage

internal_make_wflw_predictions(.model_tbl, .splits_obj)

Arguments

.model_tbl

The model table that is generated from a function like fast_regression_parsnip_spec_tbl(), must have a class of "tidyaml_mod_spec_tbl". This is meant to be used after the function internal_make_fitted_wflw() has been run and the tibble has been saved.

.splits_obj

The splits object from the auto_ml function. It is internal to the auto_ml_ function.

Value

A list object of workflows.

Details

Create predictions on a fitted parnsip model from a workflow object.

Author

Steven P. Sanderson II, MPH

Examples

library(recipes, quietly = TRUE)
library(dplyr, quietly = TRUE)

mod_spec_tbl <- fast_regression_parsnip_spec_tbl(
  .parsnip_eng = c("lm","glm","gee"),
  .parsnip_fns = "linear_reg"
)

rec_obj <- recipe(mpg ~ ., data = mtcars)
splits_obj <- create_splits(mtcars, "initial_split")

mod_tbl <- mod_spec_tbl |>
  mutate(wflw = internal_make_wflw(mod_spec_tbl, rec_obj))

mod_fitted_tbl <- mod_tbl |>
  mutate(fitted_wflw = internal_make_fitted_wflw(mod_tbl, splits_obj))
#> Error in terms.formula(f, specials = "id_var"): '.' in formula and no 'data' argument

internal_make_wflw_predictions(mod_fitted_tbl, splits_obj)
#> Error in UseMethod("predict"): no applicable method for 'predict' applied to an object of class "NULL"
#> [[1]]
#> # A tibble: 8 × 1
#>   .pred
#>   <dbl>
#> 1  22.8
#> 2  15.5
#> 3  15.4
#> 4  28.5
#> 5  24.7
#> 6  16.6
#> 7  16.1
#> 8  27.8
#> 
#> [[2]]
#> NULL
#> 
#> [[3]]
#> # A tibble: 8 × 1
#>   .pred
#>   <dbl>
#> 1  22.8
#> 2  15.5
#> 3  15.4
#> 4  28.5
#> 5  24.7
#> 6  16.6
#> 7  16.1
#> 8  27.8
#>