Repository navigation
feat(xai): add abstention and conformal localization to drift discriminator - #15
Merged
Merged
Conversation
MichalRedm
force-pushed
the
feat/7-abstain-conformal-localization
branch
from
October 3, 2026 20:58
62b5544 to
908ee85
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FeatureImportanceDriftAnalyzer(src/stride/xai/importance/) to isolate localized drift loci (confidence_threshold: Fast, model-agnostic margin thresholding (conformal: Principled hypothesis testing following Hammer et al. (ESANN 2026, arXiv:2602.19790) using out-of-bag calibration scores across bootstraps (dashboard/components/tabs/feature_importance_analysis.py).tests/test_feature_importance_abstain.py.Motivation
Resolves #7
In non-drifting regions ($L^c$ ) where distributions coincide ( $p_0(x) = p_1(x)$ ), the Bayes-optimal posterior error is 50% (random guess). Forcing binary discriminators to classify time periods globally causes them to overfit finite-sample noise in $L^c$ , degrading overall accuracy and diluting post-hoc feature importance with false-positive noise. Allowing the discriminator to abstain decouples drift localization from drift explanation, focusing feature attributions strictly on the subpopulation undergoing distribution shift.
Key Changes
1. Core Algorithmic Engine (
src/stride/xai/importance/)base.py: AddedAbstainStrategyclass exposingCONFIDENCE_THRESHOLDandCONFORMALconstants.__init__.py: ExportedAbstainStrategyin package exports.methods.py: Converted inputs to NumPy arrays (X_arr,y_arr) incalculate_feature_importance()to ensure robust indexing and shape consistency on filtered subsets.analysis.py:_localize_by_confidence_threshold()and_localize_by_conformal()helper methods.compute_drift_importance()with parametersabstain_strategy,tau,alpha,min_samples,n_bootstraps, andrandom_state.UserWarningwhen the drift locus contains fewer thanmin_samples.drift_coverage,selective_accuracy,rejection_rate,drifting_mask, anddrift_locus_fallback.2. Streamlit Dashboard (
dashboard/components/tabs/feature_importance_analysis.py)3. Automated Test Suite (
tests/test_feature_importance_abstain.py)abstain_strategy=None.Empirical Benchmark Across Synthetic Generators
Evaluated across pre- and post-drift windows ($N=1000$ , 500 pre-drift / 500 post-drift) comparing the unconstrained baseline against abstaining discriminators:
Key Benchmark Takeaways
Verification
ruff check .passed with 0 errorsruff format --check .passed cleanly (106 files formatted)python -m unittest discover testspassed with 28/28 tests passing and 0 failures