@@ -54,26 +54,54 @@ load_libs <- function(x, quiet, attach = FALSE) {
5454# ' `set_engine()` is used to specify which package or system will be used
5555# ' to fit the model, along with any arguments specific to that software.
5656# '
57- # ' @section Engines:
58- # ' Based on the currently loaded packages, the following lists the set of
59- # ' engines available to each model specification.
57+ # ' @details
58+ # ' In parsnip,
59+ # '
60+ # ' - the model **type** differentiates basic modeling approaches, such as random
61+ # ' forests, logistic regression, linear support vector machines, etc.,
62+ # ' - the **mode** denotes in what kind of modeling context it will be used
63+ # ' (most commonly, classification or regression), and
64+ # ' - the computational **engine** indicates how the model is fit, such as with
65+ # ' a specific R package implementation or even methods outside of R like Keras
66+ # ' or Stan.
67+ # '
68+ # ' Use [show_engines()] to get a list of possible engines for the model of
69+ # ' interest.
70+ # '
71+ # ' Modeling functions in parsnip separate model arguments into two categories:
72+ # '
73+ # ' - _Main arguments_ are more commonly used and tend to be available across
74+ # ' engines. These names are standardized to work with different engines in a
75+ # ' consistent way, so you can use the \pkg{parsnip} main argument `trees`,
76+ # ' instead of the heterogeneous arguments for this parameter from \pkg{ranger}
77+ # ' and \pkg{randomForest} packages (`num.trees` and `ntree`, respectively). Set
78+ # ' these in your model type function, like `rand_forest(trees = 2000)`.
79+ # ' - _Engine arguments_ are either specific to a particular engine or used
80+ # ' more rarely; there is no change for these argument names from the underlying
81+ # ' engine. Set these in `set_engine()`, like
82+ # ' `set_engine("ranger", importance = "permutation")`.
6083# '
61- # ' \Sexpr[stage=render,results=rd]{parsnip:::generate_set_engine_bullets()}
6284# '
6385# ' @param object A model specification.
6486# ' @param engine A character string for the software that should
6587# ' be used to fit the model. This is highly dependent on the type
6688# ' of model (e.g. linear regression, random forest, etc.).
6789# ' @param ... Any optional arguments associated with the chosen computational
68- # ' engine. These are captured as quosures and can be `tune()`.
90+ # ' engine. These are captured as quosures and can be tuned with `tune()`.
6991# ' @return An updated model specification.
7092# ' @examples
71- # ' # First, set general arguments using the standardized names
72- # ' mod <-
73- # ' logistic_reg(penalty = 0.01, mixture = 1/3) %>%
74- # ' # now say how you want to fit the model and another other options
75- # ' set_engine("glmnet", nlambda = 10)
76- # ' translate(mod, engine = "glmnet")
93+ # ' # First, set main arguments using the standardized names
94+ # ' logistic_reg(penalty = 0.01, mixture = 1/3) %>%
95+ # ' # Now specify how you want to fit the model with another argument
96+ # ' set_engine("glmnet", nlambda = 10) %>%
97+ # ' translate()
98+ # '
99+ # ' # Many models have possible engine-specific arguments
100+ # ' decision_tree(tree_depth = 5) %>%
101+ # ' set_engine("rpart", parms = list(prior = c(.65,.35))) %>%
102+ # ' set_mode("classification") %>%
103+ # ' translate()
104+ # '
77105# ' @export
78106set_engine <- function (object , engine , ... ) {
79107 mod_type <- class(object )[1 ]
@@ -107,11 +135,12 @@ set_engine <- function(object, engine, ...) {
107135# ' Display currently available engines for a model
108136# '
109137# ' The possible engines for a model can depend on what packages are loaded.
110- # ' Some ` parsnip`-adjacent packages add engines to existing models. For example,
111- # ' the `multilevelmod` package adds additional engines for the [linear_reg ()]
112- # ' model and these are not available unless `multilevelmod` is loaded.
138+ # ' Some \pkg{ parsnip} extension add engines to existing models. For example,
139+ # ' the \pkg{poissonreg} package adds additional engines for the [poisson_reg ()]
140+ # ' model and these are not available unless \pkg{poissonreg} is loaded.
113141# ' @param x The name of a `parsnip` model (e.g., "linear_reg", "mars", etc.)
114142# ' @return A tibble.
143+ # '
115144# ' @examples
116145# ' show_engines("linear_reg")
117146# ' @export
0 commit comments