fix: ensure LogisticGAM complies with scikit-learn classifier contract#579
Open
KaranSinghDev wants to merge 1 commit into
Open
fix: ensure LogisticGAM complies with scikit-learn classifier contract#579KaranSinghDev wants to merge 1 commit into
KaranSinghDev wants to merge 1 commit into
Conversation
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.
Description
This PR addresses the label-handling bug reported in #578 . It enables
LogisticGAMto behave as a standard scikit-learn classifier by auto-encoding labels and exposing required metadata.Changes
fitmethod now usesnp.uniqueto safely encode any binary labels (strings, booleans, etc.) into0/1integers before passing them to the core_pirlsengine.classes_: The fitted model now has aclasses_attribute containing the original label names, as required by scikit-learn.predictmethod now decodes the binary output back into the original label space (e.g., predicting["spam", "ham"]).ValueErrorif the data is multi-class (>2 unique labels).Testing
I have included a new test suite and confirmed that all 162 existing tests pass locally in a clean environment.
I am open to any reviews or feedback you may have regarding this implementation. and would like to hear interested people's thoughts on this.