-
-
Notifications
You must be signed in to change notification settings - Fork 1
41-Feat: sklearn friends #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request refactors the sklearn serializer into a subdirectory structure and adds support for custom estimators. The main changes include reorganizing the codebase to use openmodels.serializers.sklearn.sklearn_serializer instead of the flat openmodels.serializers.sklearn_serializer, implementing a new custom estimator loading mechanism, and updating the sklearn version compatibility.
- Refactored sklearn serializer into a subdirectory structure (
sklearn/) - Added support for custom estimators via a new
_custom_estimatormodule and constructor parameter - Updated tested sklearn version from "1.7.1" to "1.7.2"
Reviewed Changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| openmodels/serializers/sklearn/sklearn_serializer.py | Added __init__ method with custom_estimators parameter, updated documentation, changed from module-level ALL_ESTIMATORS to instance-level _all_estimators, updated TESTED_VERSIONS and producer_version logic |
| openmodels/serializers/sklearn/_custom_estimator.py | New module implementing custom estimator validation, normalization, and loading logic |
| test/test_custom_estimator.py | New comprehensive test suite for the _custom_estimator module |
| openmodels/serializers/init.py | Updated import path from flat to nested structure |
| openmodels/protocols.py | Added __init__ method to ModelSerializer protocol to allow serializers to accept constructor parameters |
| test/*.py | Updated all import statements to use new nested module structure |
| openmodels/test_helpers.py | Updated import statement to use new nested module structure |
Comments suppressed due to low confidence (2)
openmodels/serializers/sklearn/sklearn_serializer.py:305
- The comment references version '1.7.1' but TESTED_VERSIONS was updated to include '1.7.2'. This docstring should be updated to reflect the current tested versions or remove the specific version reference to avoid future inconsistency.
openmodels/serializers/sklearn/sklearn_serializer.py:225 - This class does not call ModelSerializer.init during initialization. (SklearnSerializer.init may be missing a call to a base class init)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This pull request introduces support for custom scikit-learn-compatible estimators in the
SklearnSerializer, refactors the internal organization of sklearn-related serializers, and adds comprehensive tests for the new custom estimator logic. The changes improve extensibility, maintainability, and test coverage, allowing users to serialize and deserialize third-party or custom estimators alongside built-in ones.Support for custom estimators in serialization:
SklearnSerializervia a newcustom_estimatorsparameter. These are merged into the serializer's internal registry for the instance, enabling seamless serialization/deserialization of external classes.is_valid_estimator,normalize_estimators, andload_custom_estimatorsinopenmodels/serializers/sklearn/_custom_estimator.pyto validate, normalize, and load custom estimators.SklearnSerializerto use the instance-specific registry (self._all_estimators) instead of the global one, ensuring custom estimators are recognized during (de)serialization.Refactoring and reorganization:
sklearn_serializer.pyinto a dedicatedsklearnsubpackage and updated all imports accordingly, improving codebase organization and clarity.Solves #41
SklearnSerializerto clarify the new extensibility features and provide developer guidance for third-party package maintainers.Testing improvements:
test/test_custom_estimator.pycovering all branches and edge cases of the custom estimator loading logic, including validation, normalization, error handling, and conflict resolution.Other updates:
SklearnSerializer.Protocol and interface changes:
ModelSerializerprotocol to allow arbitrary constructor arguments, supporting the new extensibility pattern.