feat: add mutual information scoring and Shannon entropy#68
Merged
maskedsyntax merged 1 commit intomainfrom Mar 3, 2026
Merged
feat: add mutual information scoring and Shannon entropy#68maskedsyntax merged 1 commit intomainfrom
maskedsyntax merged 1 commit intomainfrom
Conversation
- config.py: add MutualInfoThresholds (low_mi_warning, max_categories, min_samples, entropy_bins) wired into HashPrepConfig - summaries/mutual_info.py: new module — summarize_mutual_information() computes sklearn MI scores (mutual_info_classif for categorical targets, mutual_info_regression for numeric targets) for all eligible features, with label-encoding for categoricals; scores sorted descending and stored in summaries["mutual_information"] when a target column is set - summaries/variables.py: add _shannon_entropy() helper; embed entropy (entropy_bits + normalized_entropy) in numeric summaries (discretised into bins) and categorical summaries (from value-count probabilities) - checks/mutual_info.py: new low_mutual_information check — flags features whose MI with the target is below the configured warning threshold - checks/__init__.py + core/analyzer.py: register low_mutual_information in CHECKS and ALL_CHECKS; inject MI summary into analyzer.summaries - summaries/__init__.py: export summarize_mutual_information - tests/test_mutual_info.py: 28 tests covering entropy in summaries, MI computation correctness, low_mi check unit, and end-to-end integration; threshold-sensitive tests use per-test seeded RNGs and n=2000 to avoid KNN estimator variance; all 208 tests pass (180 existing + 28 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
Shannon entropy in variable summaries:
entropy_bits+normalized_entropyfrom value-count probabilities_shannon_entropy()returnsNonefor constant columns (< 2 distinct values)summarize_mutual_information()insummaries/mutual_info.py:mutual_info_classiformutual_info_regressionfrom sklearnsummaries["mutual_information"]when a target column is setlow_mutual_informationcheck inchecks/mutual_info.py:target_colto be set; no-op otherwiseConfig:
MutualInfoThresholdsadded toconfig.pywithlow_mi_warning,max_categories_for_mi,min_samples_for_mi, andentropy_bins28 new tests in
tests/test_mutual_info.py. Threshold-sensitive tests use per-test seeded RNGs and n=2000 to avoid KNN estimator variance. All 208 tests pass (180 existing + 28 new).Test plan
uv run pytest tests/test_mutual_info.py -v28/28 passuv run pytest tests/ --ignore=tests/test_mutual_info.py -q180/180 passuv run ruff check . && uv run ruff format --check .clean