Add sklearn-compatible wrappers for LinearGAM, LogisticGAM, PoissonGAM#563
Open
mbilgesu wants to merge 1 commit intodswah:mainfrom
Open
Add sklearn-compatible wrappers for LinearGAM, LogisticGAM, PoissonGAM#563mbilgesu wants to merge 1 commit intodswah:mainfrom
mbilgesu wants to merge 1 commit intodswah:mainfrom
Conversation
Author
|
Hi @dswah — I've opened PR #563 which takes a different approach to #422 than the existing PRs. |
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.
Closes #422
pyGAM estimators currently break with sklearn>=1.7 and cannot be used
with Pipeline, GridSearchCV, or cross_val_score due to two root causes:
__sklearn_tags__missing — fixed by inheriting from BaseEstimator__init__(callbacks,terms) — breaks clone()Rather than patching the core classes, this PR adds a
pygam/compat.pymodule with clean wrapper classes that fully satisfy sklearn's estimator
contract without touching existing behaviour:
SklearnLinearGAM— RegressorMixin + BaseEstimatorSklearnLogisticGAM— ClassifierMixin + BaseEstimator (classes_, predict_proba, decision_function)SklearnPoissonGAM— RegressorMixin + BaseEstimatorAll wrappers use
validate_data()for fit/predict consistency checks,store only plain scalars in
__init__(clone-safe), and returnselffrom fit().
Tests (pygam/tests/test_compat.py):
20/20 tests pass on Python 3.13 + sklearn 1.7+.