Feat: Add model persistence (save/load methods)#492
Open
Ahmed-Zahran02 wants to merge 5 commits intodswah:mainfrom
Open
Feat: Add model persistence (save/load methods)#492Ahmed-Zahran02 wants to merge 5 commits intodswah:mainfrom
Ahmed-Zahran02 wants to merge 5 commits intodswah:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds first-class model persistence APIs to pyGAM by introducing save() / load() for pickled on-disk serialization, along with to_dict() / from_dict() helpers intended for JSON-serializable export/import, plus tests covering roundtrips and versioning.
Changes:
- Added
GAM.save()/GAM.load()with optional gzip compression and serialization version metadata. - Added
GAM.to_dict()/GAM.from_dict()for dictionary-based serialization. - Added a new serialization test suite covering save/load, compression, version errors, and direct pickling.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
pygam/pygam.py |
Implements serialization/versioning hooks and the new save/load + dict export/import APIs. |
pygam/tests/test_serialization.py |
Adds unit tests for persistence roundtrips, compression, versioning, and dict JSON-serializability. |
pygam/__init__.py |
Exposes SERIALIZATION_VERSION at the package level. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…to add-model-export
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 #491
Description
This PR implements model persistence for pyGAM models by adding save and load methods. This allows users to serialize trained models and restore them without retraining, addressing the need for model deployment and reuse.
I have added unit tests to verify:
Checklist