
Generate Model Specification calls to parsnip
Source: R/make-classification-fast.R
fast_classification.Rd
Creates a list/tibble of parsnip model specifications.
Usage
fast_classification(
.data,
.rec_obj,
.parsnip_fns = "all",
.parsnip_eng = "all",
.split_type = "initial_split",
.split_args = NULL
)
Arguments
- .data
The data being passed to the function for the classification problem
- .rec_obj
The recipe object being passed.
- .parsnip_fns
The default is 'all' which will create all possible classification model specifications supported.
- .parsnip_eng
the default is 'all' which will create all possible classification model specifications supported.
- .split_type
The default is 'initial_split', you can pass any type of split supported by
rsample
- .split_args
The default is NULL, when NULL then the default parameters of the split type will be executed for the rsample split type.
Details
With this function you can generate a tibble output of any classification
model specification and it's fitted workflow
object. Per recipes documentation
explicitly with step_string2factor()
it is encouraged to mutate your predictor
into a factor before you create your recipe.
See also
Other Model_Generator:
create_model_spec()
,
fast_regression()
Examples
library(recipes, quietly = TRUE)
library(dplyr, quietly = TRUE)
df <- mtcars |> mutate(cyl = as.factor(cyl))
rec_obj <- recipe(cyl ~ ., data = df)
fct_tbl <- fast_classification(
.data = df,
.rec_obj = rec_obj,
.parsnip_eng = c("glm","LiblineaR"))
#> Warning: There were 4 warnings in `dplyr::mutate()`.
#> The first warning was:
#> ℹ In argument: `fitted_wflw = internal_make_fitted_wflw(mod_tbl, splits_obj)`.
#> Caused by warning:
#> ! ! Logistic regression is intended for modeling binary outcomes, but there are 3
#> levels in the outcome.
#> ℹ If this is unintended, adjust outcome levels accordingly or see the
#> `multinom_reg()` function.
#> ℹ Run `dplyr::last_dplyr_warnings()` to see the 3 remaining warnings.
glimpse(fct_tbl)
#> Rows: 3
#> Columns: 8
#> $ .model_id <int> 1, 2, 3
#> $ .parsnip_engine <chr> "glm", "LiblineaR", "LiblineaR"
#> $ .parsnip_mode <chr> "classification", "classification", "classification"
#> $ .parsnip_fns <chr> "logistic_reg", "logistic_reg", "svm_linear"
#> $ model_spec <list> [~NULL, ~NULL, NULL, classification, TRUE, NULL, glm, …
#> $ wflw <list> [mpg, disp, hp, drat, wt, qsec, vs, am, gear, carb, cy…
#> $ fitted_wflw <list> [mpg, disp, hp, drat, wt, qsec, vs, am, gear, carb, cy…
#> $ pred_wflw <list> [<tbl_df[8 x 1]>], [<tbl_df[8 x 1]>], [<tbl_df[8 x 1]>…