Fix Scikit-Learn API compliance and GridSearchCV support (#340, #482)#490
Open
VanshKharb wants to merge 9 commits intodswah:mainfrom
Open
Fix Scikit-Learn API compliance and GridSearchCV support (#340, #482)#490VanshKharb wants to merge 9 commits intodswah:mainfrom
VanshKharb wants to merge 9 commits intodswah:mainfrom
Conversation
- Save original initialization params before `GAM.fit()` mutates them - Override `get_params(deep=False)` to restore original params for `sklearn.clone()` - Add `__sklearn_clone__` to `Term` and `TermList` to prevent empty list duck-typing - Remove redundant `gam.set_params` calls in internal bootstrap/gridsearch - Add regression tests for cloning fitted GAMs with custom terms
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.
Summary
This PR resolves several compatibility issues with Scikit-Learn estimators, specifically addressing #340 (
sklearn.cloneattribute mutation) and #482 (GridSearchCVfailures). Following these changes, pyGAM models now pass the fullsklearn.utils.estimator_checks.check_estimatorsuite.Detailed Changes
GAM.get_params()to return the original un-mutated init arguments. Previously, standard string arguments were replaced with objects during fit(), which causedsklearn.clone()to fail.LogisticGAM.fit()now defines theclasses_attribute, and predict() correctly maps outputs to these class labels instead of returning boolean masks.TypeErrorexceptions in check_array(), check_X(), and check_y() to correctly handle 1D arrays, dense requirement for sparse matrices, and zero-feature arrays based on Scikit-Learn guidelines.n_iter_tracking toGAM._pirlsto satisfy iterations checks.Testing
GridSearchCVcompatibility with LogisticGAM.pygam/testspass.