Add save/load methods to anomaly detection classes - #3130
Open
robrui wants to merge 2 commits into
Open
Conversation
dennisbader
requested changes
Jun 26, 2026
dennisbader
left a comment
Collaborator
There was a problem hiding this comment.
Hi @robrui and thanks a lot for this PR 🚀
I see currently a lot of duplicate code. Could you try to unify the logic (maybe using the existing logic for the ForecastingModel)?
Contributor
Author
|
Thanks @dennisbader! You're right about the duplication. I pulled the common save/load logic into a shared base mixin so all four AD classes inherit from it now — same behavior, much less code. |
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.
Checklist before merging this PR:
Fixes #3051.
Summary
Adds
save()andload()methods to the four anomaly detection base classes (AnomalyScorer, Detector, Aggregator, AnomalyModel). This makes it possible to persist trained scorers like KMeansScorer, detectors like QuantileDetector, aggregators, and anomaly models to disk and reload them later without retraining. Uses the same pickle-based approach as ForecastingModel.save/load.Other Information
All subclasses inherit save/load automatically. The full anomaly detection test suite passes (229 tests).