View source: R/as_classbound.R
| as_classbound | R Documentation |
Wraps a pre-fitted model in a classbound object, adding the feature metadata
(names, types, ranges, imputation values) required by boundary_compute() and
plot_boundary(). This is the entry point for "bring your own model" (BYO) workflows,
including native tidymodels workflows and parsnip model fits.
as_classbound(model, data, response = NULL, ...)
model |
A fitted model object. For |
data |
A data frame of the training data. Used only to extract feature metadata;
the data is not passed through |
response |
Optional string naming the response column in |
... |
Additional arguments passed to methods. |
Unlike fit_model(), as_classbound() does not refit the model or call
preprocess_data(). Feature metadata is extracted solely from the data argument,
which should be the same data used to fit the model. If the model was fitted on
scaled or transformed data, ensure data reflects that transformation.
as_classbound() dispatches on the class of model:
Default: wraps any fitted model object (e.g., rpart, lda).
workflow: requires the workflow to already be trained (via fit()). Use
boundary_workflow_set() to train and wrap an entire workflow set at once.
model_fit: wraps a fitted parsnip model.
A classbound object ready for use with boundary_compute() and
plot_boundary().
fit_model(), boundary_workflow_set(), boundary_compute()
library(palmerpenguins)
data(penguins)
peng_data <- na.omit(penguins[, c("species", "bill_length_mm", "bill_depth_mm")])
# Wrap any pre-fitted model
raw_model <- rpart::rpart(species ~ ., data = peng_data)
cb_model <- as_classbound(raw_model, data = peng_data, response = "species")
# Tidymodels: wrap a fitted workflow
# (boundary_workflow_set() does this automatically for entire workflow sets)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.