Skip to content

fix: ensure LogisticGAM complies with scikit-learn classifier contract#579

Open
KaranSinghDev wants to merge 1 commit into
dswah:mainfrom
KaranSinghDev:feature/logisticgam-sklearn-compliance
Open

fix: ensure LogisticGAM complies with scikit-learn classifier contract#579
KaranSinghDev wants to merge 1 commit into
dswah:mainfrom
KaranSinghDev:feature/logisticgam-sklearn-compliance

Conversation

@KaranSinghDev
Copy link
Copy Markdown

Description

This PR addresses the label-handling bug reported in #578 . It enables LogisticGAM to behave as a standard scikit-learn classifier by auto-encoding labels and exposing required metadata.

Changes

  1. Auto-Encoding: The fit method now uses np.unique to safely encode any binary labels (strings, booleans, etc.) into 0/1 integers before passing them to the core _pirls engine.
  2. Expose classes_: The fitted model now has a classes_ attribute containing the original label names, as required by scikit-learn.
  3. Predict with Original Labels: The predict method now decodes the binary output back into the original label space (e.g., predicting ["spam", "ham"]).
  4. Validation: Added explicit logic to raise a ValueError if 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant