Skip to main content

Module drift

Module drift 

Source
Expand description

Data drift and distribution shift detection

This module provides multivariate drift detection for monitoring feature distributions over time between a reference dataset and a current (production) dataset.

§Methods

MethodDescription
DriftMethod::KolmogorovSmirnov2-sample KS test per feature with asymptotic p-value
DriftMethod::PopulationStabilityIndexBinning-based PSI score
DriftMethod::WassersteinW1 (Earth mover’s) distance per feature
DriftMethod::MaximumMeanDiscrepancyMMD² with RBF kernel (multivariate)

§Example

use scirs2_transform::drift::{DriftDetector, DriftDetectorConfig, DriftMethod};
use scirs2_core::ndarray::Array2;

let reference = Array2::<f64>::zeros((100, 3));
let config = DriftDetectorConfig::default();
let detector = DriftDetector::fit(&reference, config);

let current = Array2::<f64>::zeros((80, 3));
let report = detector.detect(&current).expect("detection should succeed");
assert!(!report.drifted, "identical distributions should not drift");

Structs§

DriftDetector
Multivariate drift detector that compares a reference distribution against a current (test) distribution feature by feature.
DriftDetectorConfig
Configuration for a DriftDetector.
DriftReport
Report produced by DriftDetector::detect.

Enums§

DriftMethod
Method used for drift detection.

Functions§

ks_test
Compute the 2-sample KS statistic and asymptotic p-value for two 1D samples.
mmd_rbf
Compute MMD² with RBF kernel for two 1D sample arrays.
psi
Compute PSI between a reference and current 1D distribution.
wasserstein_distance_1d
Compute the W1 (Wasserstein-1) distance between two 1D empirical distributions.