Fit a Model Specification to a Dataset
fit will take a model specification, finalize the required
code by substituting arguments, and execute the model fit
# S3 method for model_spec fit(object, x, engine = object$engine, .control = list(verbosity = 1, catch = FALSE), ...)
An object of class
Other options required to fit the model. If
xis a formula or recipe, then the
dataargument should be passed here. For the "x/y" interface, the outcome data should be passed in with the argument
Either an R formula, a data frame of predictors, or a recipe object.
A character string for the software that should be used to fit the model. This is highly dependent on the type of model (e.g. linear regression, random forest, etc.).
A named list with elements
verbosityshould be an integer where a value of zero indicates that no messages or output should be shown when packages are loaded or when the model is fit. A value of 1 means that package loading is quiet but model fits can produce output to the screen (depending on if they contain their own
verbose-type argument). A value of 2 or more indicates that any output should be seen.
catchis a logical where a value of
TRUEwill evaluate the model inside of
try(, silent = TRUE). If the model fails, an object is still returned (without an error) that inherits the class "try-error".
fit substitutes the current arguments in the model
specification into the computational engine's code, checks them
for validity, then fits the model using the data and the
engine-specific code. Different model functions have different
interfaces (e.g. formula or
between the interface used when
fit was invoked and the one
required by the underlying model.
fit attempts to avoid making copies of the
data. For example, if the underlying model uses a formula and
fit is invoked with a formula, the original data are references
when the model is fit. However, if the underlying model uses
something else, such as
y, the formula is evaluated and
the data are converted to the required format. In this case, any
calls in the resulting model objects reference the temporary
objects used to fit the model.
An object for the fitted model.