Fix MFA column-output labels for categorical/MultiIndex groups (#242) - #243
Merged
Conversation
Column outputs now use a clean 2-level (group, variable) MultiIndex,
consistent with the partial outputs. Categorical indicator labels read
(group, "var__category") instead of the stringified
"('group', 'var')__category" prefix that pandas.get_dummies produced from
tuple column labels.
The X-taking MFA.column_coordinates method previously raised AttributeError
(it delegated to a non-existent PCA.column_coordinates); it now raises an
explicit NotImplementedError. A FactoMineR-matching implementation needs
category barycenters (quali.var$coord) and is left for a follow-up.
Bumps version to 0.20.1.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Fixes #242.
Problem
For an MFA with categorical groups and
MultiIndexcolumns, the column outputs had two issues the reporter flagged:pandas.get_dummiesstringified the tuple column label as the one-hot prefix, producing"('treatment', 'arm')__control"instead of something structured.Indexof mixed tuples/strings, inconsistent with the partial outputs (which use aMultiIndex).I also found a latent third bug: the
MFA.column_coordinates(X)method raisedAttributeErrorbecause it delegated to a non-existentPCA.column_coordinates.Fix
column_coordinates_,column_correlations,column_contributions_,column_cosine_similarities_) now use a clean 2-level(group, variable)MultiIndex:(group, var)e.g.("chemical", "shared")(group, "var__category")e.g.("treatment", "arm__control"), matching MCA's existingvar__categoryconvention.MFA.column_coordinates(X)now raises an explicitNotImplementedError. A FactoMineR-matching implementation requires category barycenters (quali.var$coord) rather than the indicator-column loadings exposed bycolumn_coordinates_, and is left for a follow-up.Tests
test_column_coordinates_index(inTestMFACategorical, runs across all supplementary-row / supplementary-group combinations): asserts the 2-level MultiIndex, cleanvar__categorylabels, no stringified tuples, and that derived outputs share the index.test_column_coordinates_method_not_implemented: the method raisesNotImplementedError.test_column_coordinates_labels_issue_242: standalone reproduction of the issue's exact example.Full suite passes (674 passed, 2 skipped);
tyandruffare clean.Bumps version to 0.20.1.
🤖 Generated with Claude Code