View source: R/predict_model.R
| predict_model | R Documentation |
Generates predictions using a unified interface across all classifiers.
This function is a compatibility wrapper around the standard predict() method for "classbound" objects.
predict_model(model, newdata, predict_args = list(), predfun = NULL, ...)
model |
A fitted classbound model. This corresponds to the |
newdata |
A data frame of new observations to predict on. |
predict_args |
A named list of additional arguments passed to |
predfun |
A custom function to generate predictions for non-standard models.
The function must accept at least two arguments: |
... |
Additional arguments passed to the specific model adapter. |
A list containing class (a factor of predicted labels) and probs
(a probability matrix, or strictly NULL if the classifier lacks probability support).
library(palmerpenguins)
data(penguins)
peng_data <- na.omit(penguins[, c("species", "bill_length_mm", "bill_depth_mm")])
m_rpart <- fit_model(peng_data, species ~ ., rpart::rpart)
preds <- predict_model(m_rpart, newdata = peng_data[1:5, ])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.