Simplify and fix InformationWeight Transform with column groups#153
Open
ryandewolfe33 wants to merge 7 commits into
Open
Simplify and fix InformationWeight Transform with column groups#153ryandewolfe33 wants to merge 7 commits into
ryandewolfe33 wants to merge 7 commits into
Conversation
lmcinnes
approved these changes
Jul 20, 2026
There was a problem hiding this comment.
Pull request overview
This PR fixes incorrect behavior in InformationWeight when combining supervision (target) with column_groups, and simplifies the implementation by consolidating baseline computation and removing the single_column_group_weight interface path.
Changes:
- Add group-aware baseline marginal computation used consistently for both supervised and unsupervised information weighting.
- Update supervised weighting to support column-group-aware baselines in
InformationWeightTransformer.fit. - Consolidate/parameterize information-weight transformer tests and remove coverage for
single_column_group_weight.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
vectorizers/transformers/info_weight.py |
Refactors baseline probability computation, removes single_column_group_weight, and fixes grouped+supervised weighting flow. |
vectorizers/tests/test_transformers.py |
Consolidates IW transformer tests into a single parametrized test covering more fit argument combinations. |
Comments suppressed due to low confidence (1)
vectorizers/transformers/info_weight.py:90
supervised_column_klcan return NaN whenbaseline_probabilitiescontains zeros (common when a class has zero mass within a column group). The expressionobserved * np.log(observed / baseline_probabilities)produces0 * log(0/0)=> NaN, which then propagates into weights.
observed += prior_strength * baseline_probabilities
observed /= observed.sum()
return np.sum(observed * np.log(observed / baseline_probabilities))
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
The initial PR #150 that added column groups to the information weight transform added a few more branching paths and had an error (silent, answers were wrong) when both column groups and targets were passed. This PR fixes that error and simplifies the code. I also consolidated the info weight tests into a single test with more parameters.
I have also changed the interface to remove the
single_column_group_weightparameter to simplify and since I am not sure why it would be used. I hope this is okay because there was no release since the last PR