Skip to contents

Scans features for statistical and temporal data leakage against a binary outcome. Checks:

  1. Zero variance.

  2. Deterministic stratum separation (pure 0 or 1 outcome rates in feature strata).

  3. Single-feature AUC above threshold.

  4. Temporal leakage (feature dates occurring after index date).

Usage

leakage_scan(
  X,
  y,
  index_date = NULL,
  feature_dates = NULL,
  max_auc = 0.98,
  min_stratum_n = 10
)

Arguments

X

Data frame of clinical features (or data frame containing features and outcome).

y

Binary outcome indicator (0 or 1), or string column name in X.

index_date

Optional index admission/anchor date(s) to verify temporal sequencing.

feature_dates

Optional named list or data frame mapping feature names to dates.

max_auc

Maximum allowable single-feature AUC before flagging (default 0.98).

min_stratum_n

Minimum stratum size to evaluate pure 0/1 separation (default 10).

Value

A data frame with columns: feature, check, value, threshold, flagged, details.