| borg_inspect | R Documentation |
borg_inspect() examines R objects for signals of information reuse that
would invalidate model evaluation. It returns a structured assessment of
detected risks.
borg_inspect(
object,
train_idx = NULL,
test_idx = NULL,
data = NULL,
target = NULL,
coords = NULL,
...
)
object |
An R object to inspect. Supported types include:
|
train_idx |
Integer vector of training row indices. Required for data-level inspection. |
test_idx |
Integer vector of test row indices. Required for data-level inspection. |
data |
Optional data frame. Required when inspecting preprocessing objects to compare parameters against train-only statistics. |
target |
Optional name of the target/outcome column. If provided, checks for target leakage (features highly correlated with target). |
coords |
Optional character vector of coordinate column names. If provided, checks spatial separation between train and test. |
... |
Additional arguments passed to type-specific inspectors. |
borg_inspect() dispatches to type-specific inspectors based on the class
of the input object. Each inspector looks for specific leakage patterns:
Checks if parameters (mean, sd, loadings) were computed on data that includes test indices
Validates that train/test indices do not overlap and that grouping structure is respected
Checks if encodings, embeddings, or derived features used test data during computation
A BorgRisk object containing:
List of detected risk objects
Count of hard violations
Count of soft inflation warnings
TRUE if no hard violations detected
borg_validate for complete workflow validation,
borg for automated enforcement during evaluation.
# Inspect a preprocessing object
data(mtcars)
train_idx <- 1:25
test_idx <- 26:32
# BAD: preProcess fitted on full data (will detect leak)
pp_bad <- scale(mtcars[, -1])
# GOOD: preProcess fitted on train only
pp_good <- scale(mtcars[train_idx, -1])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.