View source: R/borg_pipeline.R
| borg_pipeline | R Documentation |
Walks a tidymodels workflow() or caret::train() object and
validates every step — preprocessing, feature selection, tuning, and
model fitting — for information leakage.
borg_pipeline(pipeline, train_idx, test_idx, data = NULL, ...)
pipeline |
A modeling pipeline object. Supported types:
|
train_idx |
Integer vector of training row indices. |
test_idx |
Integer vector of test row indices. |
data |
Optional data frame. Required for parameter-level checks. |
... |
Additional arguments passed to inspectors. |
borg_pipeline() decomposes a pipeline into stages and inspects each:
Preprocessing: Recipe steps, preProcess, PCA, scaling
Feature selection: Variable importance, filtering
Hyperparameter tuning: Inner CV resamples
Model fitting: Training data scope, row counts
Post-processing: Threshold optimization, calibration
Each stage gets its own BorgRisk assessment. The overall result aggregates all risks across stages.
An object of class "borg_pipeline" containing:
Named list of per-stage BorgRisk results
Aggregated BorgRisk for the full pipeline
Number of stages inspected
Character vector of stage names with hard violations
borg_validate, borg_inspect
if (requireNamespace("caret", quietly = TRUE)) {
ctrl <- caret::trainControl(method = "cv", number = 5)
model <- caret::train(mpg ~ ., data = mtcars[1:25, ], method = "lm",
trControl = ctrl, preProcess = c("center", "scale"))
result <- borg_pipeline(model, train_idx = 1:25, test_idx = 26:32,
data = mtcars)
print(result)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.