-
-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Feature: Add Support for LocalOutlierFactor in Sklearn Serializer
Summary
The OpenModels sklearn serializer currently does not support the LocalOutlierFactor (LOF) estimator from scikit-learn. Attempting to serialize or deserialize a LocalOutlierFactor instance results in an AttributeError: This 'LocalOutlierFactor' has no attribute 'predict'. This is because LOF does not implement a predict method unless novelty=True, and its API differs from most other estimators.
Motivation
- Completeness:
LocalOutlierFactoris a widely used anomaly detection algorithm and should be supported by the serializer. - User Experience: Users expect all standard scikit-learn estimators to be serializable/deserializable without errors, including those with non-standard APIs.
- Correctness: The serializer should handle estimators that do not implement
predictor have special requirements for serialization.
Error Details
- Error:
AttributeError: This 'LocalOutlierFactor' has no attribute 'predict' - Context:
This error occurs becauseLocalOutlierFactoronly exposes apredictmethod if it is constructed withnovelty=True. Otherwise, it is intended for outlier detection on the training set only, usingfit_predictandnegative_outlier_factor_.
References
Suggested Tasks
- Investigate the internal structure and API of
LocalOutlierFactor, especially the difference in behavior whennovelty=Truevsnovelty=False. - Update the serializer to correctly handle serialization and deserialization of
LocalOutlierFactor, including its fitted attributes (e.g.,negative_outlier_factor_,n_neighbors_, etc.). - Ensure that the absence of a
predictmethod whennovelty=Falsedoes not cause errors during serialization or deserialization. - Add tests to ensure that
LocalOutlierFactorcan be round-tripped (serialized and deserialized) for bothnovelty=Trueandnovelty=Falsecases. - Remove
"LocalOutlierFactor"from theNOT_SUPPORTED_ESTIMATORSlist insklearn_serializer.pyonce support is complete.
Acceptance Criteria
LocalOutlierFactorcan be serialized and deserialized without errors for bothnovelty=Trueandnovelty=False.- All relevant parameters and fitted attributes are preserved.
- Tests are added to cover typical usage of
LocalOutlierFactor. "LocalOutlierFactor"is no longer listed inNOT_SUPPORTED_ESTIMATORS.
Related file: openmodels/serializers/sklearn/sklearn_serializer.py
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Projects
Status
Backlog