Add zero-sum encoding option for categorical predictors#973
Open
Chirag3841 wants to merge 1 commit into
Open
Conversation
Collaborator
|
@Chirag3841, thanks for the initiative to start this contribution. I'm afraid supporting zero-sum encoding in Bambi is a way more complex endeavor than what this PR attempts to do. For instance, we'd need to modify the model-building library, formulae, to return non-full rank matrices in cases we want to use ZeroSum normal. And then we'd need to modify multiple parts of Bambi to account for that change. The addition of a model-level argument is not a suitable solution, as the encoding of each categorical covariate is controlled at the covariate level. |
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.
Thank your for opening a PR!
Before you proceed, please check the following notes.
In particular, pay attention to:
Issue #941
Description
This PR adds support for an alternative categorical encoding strategy using a zero-sum constraint via pm.ZeroSumNormal.
Users can now choose between "reference" (default) and "zero-sum" encoding through the new categorical_encoding argument in bmb.Model.
Changes done
Added categorical_encoding argument to bmb.Model
Implemented "zero-sum" encoding for categorical predictors in PyMC backend using pm.ZeroSumNormal
Added unit test to verify model builds correctly with categorical_encoding="zero-sum"