Skip to content

Add save/load methods to anomaly detection classes#3129

Closed
robrui wants to merge 1 commit into
unit8co:masterfrom
robrui:feature/3051-anomaly-save-load
Closed

Add save/load methods to anomaly detection classes#3129
robrui wants to merge 1 commit into
unit8co:masterfrom
robrui:feature/3051-anomaly-save-load

Conversation

@robrui

@robrui robrui commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Checklist before merging this PR:

  • Mentioned all issues that this PR fixes or addresses.
  • Summarized the updates of this PR under Summary.
  • Added an entry under Unreleased in the Changelog.

Fixes #3051.

Summary

Adds save() and load() 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).

@robrui robrui closed this Jun 4, 2026
@codecov

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.51948% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.41%. Comparing base (b0ccd3a) to head (a89f247).

Files with missing lines Patch % Lines
darts/ad/aggregators/aggregators.py 78.94% 4 Missing ⚠️
darts/ad/anomaly_model/anomaly_model.py 78.94% 4 Missing ⚠️
darts/ad/detectors/detectors.py 78.94% 4 Missing ⚠️
darts/ad/scorers/scorers.py 85.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3129      +/-   ##
==========================================
- Coverage   96.55%   96.41%   -0.14%     
==========================================
  Files         160      160              
  Lines       17285    17362      +77     
==========================================
+ Hits        16689    16740      +51     
- Misses        596      622      +26     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add save() and load() methods toKMeansScorer

1 participant