predict_model: Predict using a fitted classbound model

View source: R/predict_model.R

predict_modelR Documentation

Predict using a fitted classbound model

Description

Generates predictions using a unified interface across all classifiers. This function is a compatibility wrapper around the standard predict() method for "classbound" objects.

Usage

predict_model(model, newdata, predict_args = list(), predfun = NULL, ...)

Arguments

model

A fitted classbound model. This corresponds to the object argument used by the standard R predict() generic. This wrapper calls predict(model, ...).

newdata

A data frame of new observations to predict on.

predict_args

A named list of additional arguments passed to predict_adapter.

predfun

A custom function to generate predictions for non-standard models. The function must accept at least two arguments: model (the fitted native model) and newdata (a data frame of new observations). It should return either a vector/factor of predicted classes, or a list containing class (predicted labels) and probs (a probability matrix).

...

Additional arguments passed to the specific model adapter.

Value

A list containing class (a factor of predicted labels) and probs (a probability matrix, or strictly NULL if the classifier lacks probability support).

Examples


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, ])


classbound documentation built on Sept. 30, 2026, 5:13 p.m.