feat: add normality and variance homogeneity statistical tests#67
Merged
maskedsyntax merged 2 commits intomainfrom Mar 3, 2026
Merged
feat: add normality and variance homogeneity statistical tests#67maskedsyntax merged 2 commits intomainfrom
maskedsyntax merged 2 commits intomainfrom
Conversation
- config.py: add StatisticalTestThresholds (normality p-value, Shapiro
max-n cutoff, min sample size, Levene p-value and min group size)
wired into HashPrepConfig
- checks/statistical_tests.py: two new checks —
- normality: Shapiro-Wilk (n ≤ 5000) or D'Agostino-Pearson (n > 5000)
per numeric column; flags non-normal distributions with stat + p-value
in the issue description
- variance_homogeneity: Levene's test (median-centred, robust) across
target-column groups; reports std ratio alongside the test result;
skipped when no target column is set or groups are too small
- summaries/variables.py: embed normality result (test name, statistic,
p_value, is_normal bool) into each numeric column's summary dict; also
fix a pre-existing crash where infinite values in a column caused
np.histogram to receive range=(-inf, inf) — all distribution stats
now computed on finite-only values
- checks/__init__.py + core/analyzer.py: register normality and
variance_homogeneity in CHECKS registry and ALL_CHECKS list
- tests/test_statistical_tests.py: 30 tests covering normality check
unit, Levene check unit, summary embedding, and end-to-end integration
via DatasetAnalyzer; all 180 tests pass (150 existing + 30 new)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
checks/statistical_tests.py:normality: Shapiro-Wilk for n <= 5,000; D'Agostino-Pearson for larger samples. Flags non-normal numeric columns with statistic + p-value in the issue description. Severity iscriticalat p < 0.001,warningotherwise.variance_homogeneity: Levene's test (median-centred, robust to non-normality) across groups defined by the target column. Reports std ratio between groups. Skipped automatically when no target column is set or groups are too small._summarize_numericnow embedsnormality: {test, statistic, p_value, is_normal}directly in each numeric column's summary dict: visible in JSON/HTML/Markdown reports without needing to run the check separately._summarize_numericwas crashing when a column containedinfvalues (np.histogramwithrange=(-inf, inf)). All distribution statistics (quantiles, histogram, MAD, skewness, etc.) are now computed on finite-only values;infinite_countstill reflects the raw column.StatisticalTestThresholdsadded toconfig.pywith all tunable knobs (p-values, cutoffs, min group sizes).tests/test_statistical_tests.py. All 180 tests pass (150 existing + 30 new).Test plan
uv run pytest tests/test_statistical_tests.py -v30/30 passuv run pytest tests/ --ignore=tests/test_statistical_tests.py -q150/150 pass (no regressions)uv run ruff check .clean