-
Notifications
You must be signed in to change notification settings - Fork 0
Drift Detection
Giacomo Saccaggi edited this page Jun 19, 2026
·
1 revision
Monitor production data for distribution shifts using PSI and KS tests.
| Metric | What it detects | Threshold |
|---|---|---|
| PSI (Population Stability Index) | Overall distribution shift | > 0.2 = significant drift |
| KS test (Kolmogorov-Smirnov) | Maximum difference between CDFs | p-value < 0.05 = drift |
A feature is flagged as "drifted" if either PSI or KS detects it.
from scomp_link import DriftDetector
# Fit on training (reference) data
detector = DriftDetector(X_train, psi_threshold=0.2, ks_alpha=0.05)
# Check production data
report = detector.detect(X_production)
# Returns DataFrame: feature, psi, psi_drifted, ks_statistic, p_value, ks_drifted, drifted
summary = detector.summary(report)
# {'total_features': 10, 'drifted_features': 2, 'drift_pct': 20.0, ...}
# Visualize
fig = detector.plot_drift_report(report) # PSI bar chart
fig = detector.plot_feature_distribution('age', X_production) # overlay histogramscomp-link drift --reference train.csv --current production.csv --threshold 0.2# The artifact stores sample data — use it as reference
artifact = ScompArtifact.load("model.scomp")
detector = DriftDetector(artifact.sample_data)
report = detector.detect(new_production_data)