Skip to content

Mad ad optimization#91

Merged
Perimora merged 2 commits intodevelopfrom
mad_ad_optimization
Dec 17, 2025
Merged

Mad ad optimization#91
Perimora merged 2 commits intodevelopfrom
mad_ad_optimization

Conversation

@Perimora
Copy link
Copy Markdown

pr for sprint09

…egy pattern. added architecture documentation

Signed-off-by: Christoph Huy <christoph.huy@campus.tu-berlin.de>
Signed-off-by: Christoph Huy <christoph.huy@campus.tu-berlin.de>
Copilot AI review requested due to automatic review settings December 17, 2025 09:01
@Perimora Perimora merged commit 198597d into develop Dec 17, 2025
2 of 13 checks passed
Copy link
Copy Markdown

Copilot AI left a 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 PR refactors the MAD (Median Absolute Deviation) anomaly detection implementation to improve modularity and extensibility. The changes introduce a strategy pattern for scoring algorithms and consolidate decomposition-based detection into a unified class.

  • Introduced MadScorer interface with GlobalMadScorer and RollingMadScorer implementations
  • Consolidated STL-based detection into DecompositionMadAnomalyDetection supporting both STL and MSTL
  • Reorganized code structure by moving MAD components into a dedicated subdirectory

Reviewed changes

Copilot reviewed 5 out of 19 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/sdk/python/rtdip_sdk/pipelines/anomaly_detection/spark/mad_anomaly_detection.py Removed original file containing three separate detector classes
src/sdk/python/rtdip_sdk/pipelines/anomaly_detection/spark/mad/mad_anomaly_detection.py New implementation with refactored MadAnomalyDetection and DecompositionMadAnomalyDetection classes using scorer strategy pattern
src/sdk/python/rtdip_sdk/pipelines/anomaly_detection/spark/mad/interfaces.py New abstract MadScorer interface defining the strategy pattern for scoring algorithms
tests/sdk/python/rtdip_sdk/pipelines/anomaly_detection/spark/test_mad.py Updated tests to use new class names and scorer implementations with added parametrized tests for decomposition methods
amos_team_resources/anomaly_detection/uml/mad_arch.xml Added UML diagram documenting the new architecture

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

from .interfaces import MadScorer


class GlobalMadScorer(MadScorer):
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Class name inconsistency: The class is named GlobalMadScorer but the UML diagram references it as MadGlobalScorer. Consider renaming to MadGlobalScorer to match the documentation.

Copilot uses AI. Check for mistakes.
return 0.6745 * (series - median) / mad


class RollingMadScorer(MadScorer):
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Class name inconsistency: The class is named RollingMadScorer but the UML diagram references it as MadRollingScorer. Consider renaming to MadRollingScorer to match the documentation.

Copilot uses AI. Check for mistakes.

def test_mad_anomaly_detection(spark_dataframe_with_anomalies):
def test_mad_anomaly_detection_global(spark_dataframe_with_anomalies):
scorer = GlobalMadScorer()
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scorer variable is instantiated but never used. The MadAnomalyDetection class already creates a default GlobalMadScorer when no scorer is provided. Either pass this scorer to the detector or remove this line.

Copilot uses AI. Check for mistakes.
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.

2 participants