Abstract
Concept drift refers to the change in the data distribution or in the relationships between variables over time. 'drifter' calculates distances between variable distributions or variable relations and identifies both types of drift. Key functions are: calculate_covariate_drift() checks distance between corresponding variables in two datasets, calculate_residuals_drift() checks distance between residual distributions for two models, calculate_model_drift() checks distance between partial dependency profiles for two models, and check_drift() executes all checks against drift. 'drifter' is a part of the 'DrWhy.AI' universe (Biecek 2018) <a href="https://doi.org/10.48550/arXiv.1806.08915" target="_top">doi:10.48550/arXiv.1806.08915</a>.
Introduction
In machine learning, the assumption that production data will mirror training data is often violated by the dynamic nature of the real world. This leads to two critical issues: Covariate Drift, where the distribution of input variables changes, and Concept Shift, where the fundamental relationship between variables and the target outcome evolves. If left unmonitored, these changes cause silent model degradation. The drifter R package addresses this by providing a systematic toolkit to quantify these shifts using methodologies from the Explainable AI (XAI) ecosystem.
Methodology
The package introduces several diagnostic layers to catch drift from multiple perspectives, primarily utilizing the Non-Intersection Distance as its core metric.
Core Metric: Non-Intersection Distance
The Non-Intersection Distance between two distributions ($P$ and $Q$) is defined as $d(P,Q) = 1 - \sum \min(P_i, Q_i)$. This provides an intuitive 0-to-1 score representing the degree to which two distributions do not overlap.
Diagnostic Layers
- Covariate Drift Detection: This layer compares feature distributions between "old" and "new" datasets. Continuous variables are discretized into equal-sized bins to facilitate the distance calculation.
- Residual Drift Detection: Instead of focusing on inputs, this method compares the distributions of model residuals (errors). Significant shifts in error distributions suggest the model is no longer capturing the underlying patterns of the current data.
- Model Drift via Partial Dependency Profiles (PDP): A novel application of PDPs, this method compares the "shape" of a variable's influence on the model's predictions. If the logic the model uses to relate a feature to an outcome changes, it indicates a concept shift.
Key Insights: XAI as a Diagnostic Tool
A central innovation of drifter is the use of interpretability tools—typically used to explain models—as diagnostic benchmarks for drift. By monitoring Partial Dependency Profiles and Ceteris Paribus profiles, researchers can detect when a model's internal logic has drifted, even if global performance metrics like accuracy remain temporarily stable. This approach aligns with the "DrWhy.AI" philosophy of Model Oriented Exploratory Data Analysis, treating the model as an object requiring constant auditing.
Key Results
The package provides a unified interface for these diagnostics, allowing for both quantitative scoring and visual validation.
The check_drift() function executes all tests simultaneously, producing a data frame of distances for every variable. This allows users to pinpoint exactly which features are drifting. Furthermore, integration with the ingredients package enables users to plot "old" versus "new" profiles, making mathematical drift scores visually interpretable for stakeholders.
Limitations and Future Work
Practitioners should be aware of several factors when using drifter:
- Binning Sensitivity: Distance calculations for continuous variables depend on the
binsparameter; inappropriate binning can mask or exaggerate drift. - Scale Dependence: Model drift calculations require a
scaleparameter (defaulting to the target variable's standard deviation), which may itself be unstable in volatile environments. - Computational Cost: Calculating PDPs for large datasets can be expensive, though the
max_obsparameter allows for subsampling to mitigate this.
Future work within the DrWhy.AI framework aims to extend these capabilities with more diverse distance metrics and automated alerting systems for production pipelines.
Summary updated