parsnip show_engines() in R: List Engines for a Model
parsnip show_engines() returns a tibble of every modeling engine registered for a parsnip model type, paired with the mode (regression or classification) each engine supports. It is the fastest way to see your options before you commit one with set_engine().
show_engines("linear_reg") # all engines for a model
show_engines("rand_forest") # engines for random forest
show_engines("boost_tree") # boosted tree engines
show_engines("rand_forest") |> filter(mode == "regression") # filter by mode
show_engines("boost_tree") |> pull(engine) # engine names only
nrow(show_engines("linear_reg")) # count available engines
show_engines("linear_reg") |> distinct(engine) # unique engines, drop modeNeed explanation? Read on for examples and pitfalls.
What show_engines() does
show_engines() is a lookup function, not a modeling function. It takes the name of a parsnip model type as a string and returns a two-column tibble listing every computational engine that can fit that model. An engine is the underlying package or system that does the real fitting work, such as lm, glmnet, ranger, or spark. parsnip wraps all of them behind one consistent interface, and show_engines() tells you which ones are on the menu.
Each row is a valid engine and mode pairing. You read this as "linear regression can be fitted by lm, glmnet, stan, and four others, all in regression mode."
multilevelmod, poissonreg, or bonsai registers extra engines, so the exact rows you see depend on your installed packages and parsnip version. The columns are always engine and mode.show_engines() syntax and arguments
show_engines() takes exactly one argument. The signature is show_engines(x), where x is a character string naming a parsnip model type. There is no mode argument and no engine argument: the function always returns the full set, and you filter the result afterwards with dplyr. The return value is a tibble with columns engine and mode, one row per valid combination.
The string you pass must match a parsnip model function name. These are the most common ones:
| Model type string | parsnip model | Typical task |
|---|---|---|
"linear_reg" |
Linear regression | Regression |
"logistic_reg" |
Logistic regression | Classification |
"rand_forest" |
Random forest | Both |
"boost_tree" |
Gradient boosting | Both |
"decision_tree" |
Decision tree | Both |
show_engines() examples
These four examples cover the use cases you hit most often. Each one starts from a model type string and shapes the result with dplyr.
A classification-capable model returns rows for more than one mode:
Filter to a single mode when you only care about one task. Here we keep just the regression engines:
Pull the engine names into a plain character vector when you want to loop over them or print a list:
Once you have picked an engine, feed it straight into set_engine() to build the model spec:
show_engines() vs set_engine() vs show_model_info()
These three functions answer different questions about engines. show_engines() discovers what is available, show_model_info() dumps the full registry detail, and set_engine() commits your choice to a model specification.
| Function | Purpose | Returns | When to use |
|---|---|---|---|
show_engines() |
List engines for a model type | Tibble of engine + mode |
Discover what is available |
show_model_info() |
Full registry detail for a model | Printed text dump | Inspect args, modes, and defaults |
set_engine() |
Attach one engine to a spec | Updated model specification | Build the model |
The decision rule is simple. Start with show_engines() to see the menu. If you need to know which tuning arguments an engine accepts, escalate to show_model_info(). Once you have decided, call set_engine() to lock it in.
show_engines("boost_tree") interactively before writing set_engine(), so you never guess an engine name and trigger an error halfway through a pipeline.Common pitfalls
Most show_engines() errors come from how you pass the model name. The argument must be a quoted string.
Passing the model function unquoted fails because R tries to evaluate it as an object:
A misspelled or unknown model type returns a clear error rather than an empty tibble:
The third trap is confusing show_engines() with show_model_info(). show_engines() gives you a tidy tibble you can filter; show_model_info() prints a long unstructured summary. Reach for the second only when you need argument-level detail.
show_engines() does not mean it is installed. The function reads the parsnip registry, not your library. show_engines("rand_forest") lists ranger even if ranger is not installed. Run install.packages() or check required_pkgs() before fitting.Try it yourself
Try it: Use show_engines() to list every engine for "boost_tree", then keep only the rows where mode is "regression". Save the result to ex_engines.
Click to reveal solution
Explanation: show_engines("boost_tree") returns every engine and mode pairing. The filter() call keeps only rows where the mode column equals "regression", dropping the classification engines.
Related parsnip functions
These functions pair naturally with show_engines() as you move from discovering an engine to fitting a model.
set_engine(): attaches a chosen engine to a model specification.set_mode(): declares regression or classification for the spec.show_model_info(): prints the full argument and mode registry for a model.translate(): reveals the exact engine-level call parsnip will run.required_pkgs(): lists the packages an engine needs before fitting.
FAQ
What is the difference between show_engines() and set_engine()?
show_engines() is read-only: it lists the engines available for a model type and returns a tibble. set_engine() is an action: it takes a model specification and one engine name, then returns an updated spec that will use that engine when fitted. You typically call show_engines() first to see your options, then call set_engine() once to commit. They are a discovery step followed by a configuration step.
Why does show_engines() return an error instead of a tibble?
The most common cause is passing an invalid model type. show_engines() expects an exact parsnip model function name as a string, such as "linear_reg" or "rand_forest". Misspellings like "linear_regression" or unquoted names like linear_reg trigger an error. Check the spelling against the parsnip documentation, and always quote the argument.
How do I see the default engine for a model?
show_engines() lists engines but does not flag a default. To find the default, print the bare model specification, for example linear_reg(). parsnip shows the default engine in the printed output. For linear_reg() the default is lm, and for rand_forest() it is ranger. You can override it any time with set_engine().
Does show_engines() need the engine packages installed?
No. show_engines() reads the internal parsnip engine registry, so it lists engines such as glmnet or xgboost whether or not those packages are installed. Installation only matters when you actually fit the model. Use required_pkgs() on a model specification to confirm which packages you still need to install.
Can show_engines() list engines for every model type at once?
No. show_engines() works on one model type per call. To survey several models, call it once per type and combine the results, for example with purrr::map_dfr() over a vector of model names. There is no single call that returns the entire registry as one tibble.