These functions extract various elements from a tune object. If they do not exist yet, an error is thrown.
extract_preprocessor() returns the formula, recipe, or variable
expressions used for preprocessing.
extract_spec_parsnip() returns the parsnip model specification.
extract_fit_parsnip() returns the parsnip model fit object.
extract_fit_engine() returns the engine specific fit embedded within
a parsnip model fit. For example, when using
"lm" engine, this returns the underlying
extract_mold() returns the preprocessed "mold" object returned
hardhat::mold(). It contains information about the preprocessing,
including either the prepped recipe, the formula terms object, or
extract_recipe() returns the recipe. The
estimated argument specifies
whether the fitted or original recipe is returned.
extract_workflow() returns the workflow object if the control option
save_workflow = TRUE was used. The workflow will only have been
estimated for objects produced by
## S3 method for class 'last_fit' extract_workflow(x, ...) ## S3 method for class 'tune_results' extract_workflow(x, ...) ## S3 method for class 'tune_results' extract_spec_parsnip(x, ...) ## S3 method for class 'tune_results' extract_recipe(x, ..., estimated = TRUE) ## S3 method for class 'tune_results' extract_fit_parsnip(x, ...) ## S3 method for class 'tune_results' extract_fit_engine(x, ...) ## S3 method for class 'tune_results' extract_mold(x, ...) ## S3 method for class 'tune_results' extract_preprocessor(x, ...)
Not currently used.
A logical for whether the original (unfit) recipe or the fitted recipe should be returned.
These functions supersede
The extracted value from the
x, as described in the
library(recipes) library(rsample) library(parsnip) set.seed(6735) tr_te_split <- initial_split(mtcars) spline_rec <- recipe(mpg ~ ., data = mtcars) %>% step_ns(disp) lin_mod <- linear_reg() %>% set_engine("lm") spline_res <- last_fit(lin_mod, spline_rec, split = tr_te_split) extract_preprocessor(spline_res) # The `spec` is the parsnip spec before it has been fit. # The `fit` is the fitted parsnip model. extract_spec_parsnip(spline_res) extract_fit_parsnip(spline_res) extract_fit_engine(spline_res) # The mold is returned from `hardhat::mold()`, and contains the # predictors, outcomes, and information about the preprocessing # for use on new data at `predict()` time. extract_mold(spline_res) # A useful shortcut is to extract the fitted recipe from the workflow extract_recipe(spline_res) # That is identical to identical( extract_mold(spline_res)$blueprint$recipe, extract_recipe(spline_res) )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.