Skip to content

Add distribution drift detection#290

Merged
JE-Chen merged 1 commit into
devfrom
feat/data-drift-batch
Jun 21, 2026
Merged

Add distribution drift detection#290
JE-Chen merged 1 commit into
devfrom
feat/data-drift-batch

Conversation

@JE-Chen

@JE-Chen JE-Chen commented Jun 21, 2026

Copy link
Copy Markdown
Member

What

Adds distribution-drift checks the stats module lacked — it had A/B experiment tests but no PSI and no KS two-sample test for "is today's data shaped like the baseline".

  • psi(reference, current, bins=10) — Population Stability Index (reference quantile bins, log-ratio per bin).
  • ks_two_sample(reference, current){statistic, p_value} (Kolmogorov distribution p-value).
  • categorical_drift(reference, current){chi_square, total_variation, categories}.
  • detect_drift(reference, current, *, threshold=0.25, bins=10){psi, drifted, ks}.

Pairs with data_profile; reuses stats.percentile.

Layers

  • Headless core: utils/data_drift/ (pure stdlib math/bisect/collections + stats, zero PySide6).
  • Facade: 4 symbols + __all__.
  • Executor: AC_detect_drift, AC_categorical_drift.
  • MCP: ac_detect_drift, ac_categorical_drift (read-only).
  • Script Builder: both under Data.
  • Tests: test/unit_test/headless/test_data_drift_batch.py (10 tests, pytest.approx for floats).
  • Docs: v82_features_doc.rst (EN + Zh) + toctrees + 3 README What's-new sections.

Verification

  • pytest test/unit_test/headless/test_data_drift_batch.py → 10 passed.
  • ruff check je_auto_control/ clean; pylint 10.00/10; bandit clean; radon CC clean.
  • Package stays Qt-free.

stats had A/B experiment tests but no Population Stability Index and no
Kolmogorov-Smirnov two-sample test for the reference-vs-current "is
today's data shaped like the baseline" check. Add psi, ks_two_sample,
categorical_drift, and a detect_drift wrapper that pair with data_profile.
Wired through facade, executor (AC_detect_drift / AC_categorical_drift),
MCP, and the Script Builder with a headless test batch and EN/Zh docs.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 55 complexity · 0 duplication

Metric Results
Complexity 55
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@JE-Chen
JE-Chen merged commit 29a2920 into dev Jun 21, 2026
16 checks passed
@JE-Chen
JE-Chen deleted the feat/data-drift-batch branch June 21, 2026 15:04
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant