Skip to content

Commit

Permalink
OA: Templates for Anomaly Prediction #1011
Browse files Browse the repository at this point in the history
  • Loading branch information
detlefarend committed Aug 23, 2024
1 parent c25be21 commit 9add598
Show file tree
Hide file tree
Showing 8 changed files with 246 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/mlpro/oa/streams/tasks/anomalypredictors/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from mlpro.oa.streams.tasks.anomalypredictors.basics import AnomalyPredictor
from mlpro.oa.streams.tasks.anomalypredictors.basics import AnomalyPredictor, AnomalyPrediction
20 changes: 18 additions & 2 deletions src/mlpro/oa/streams/tasks/anomalypredictors/basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@
## -- History :
## -- yyyy-mm-dd Ver. Auth. Description
## -- 2024-06-04 0.0.0 DA/DS Creation
## -- 2024-08-23 0.1.0 DA/DS Creation
## -------------------------------------------------------------------------------------------------

"""
Ver. 0.0.0 (2024-06-04)
Ver. 0.1.0 (2024-08-23)
This module provides ...
This module provides basic templates for online anomaly prediction in MLPro.
"""


from mlpro.bf.events import Event
from mlpro.oa.streams.tasks import OATask


Expand Down Expand Up @@ -58,3 +61,16 @@ class AnomalyPredictor (OATask):
"""

pass





## -------------------------------------------------------------------------------------------------
## -------------------------------------------------------------------------------------------------
class AnomalyPrediction (Event):
"""
...
"""

pass
76 changes: 76 additions & 0 deletions src/mlpro/oa/streams/tasks/anomalypredictors/tsf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
## -------------------------------------------------------------------------------------------------
## -- Project : MLPro - The integrative middleware framework for standardized machine learning
## -- Package : mlpro.oa.streams.tasks.anomalypredictors
## -- Module : basics.py
## -------------------------------------------------------------------------------------------------
## -- History :
## -- yyyy-mm-dd Ver. Auth. Description
## -- 2024-06-04 0.0.0 DA/DS Creation
## -- 2024-08-23 0.1.0 DA/DS Creation
## -------------------------------------------------------------------------------------------------

"""
Ver. 0.1.0 (2024-08-23)
This module provides basic templates for online anomaly prediction in MLPro.
"""


from mlpro.bf.events import Event
from mlpro.oa.streams.tasks import OATask




## -------------------------------------------------------------------------------------------------
## -------------------------------------------------------------------------------------------------
class AnomalyPredictor (OATask):
"""
The __init__ method should be documented in the class level docstring and the docstring itself
should not go beyond 100 characters length (within the dash separator). Sections inside the
docstring can be seperated like the reStructuredText format.
Parameters are documented in the Parameters section.
Public attributes of classes are documented inisde Attributes section.
Returns attronites are documented in the Returns section.
A few examples of data types: int / str / bool / list of str / tuple of int / float / None / dict.
If the parameters have default values, you should add "TYPE, optional" as part of the type
and "The default is ...." as part of the description.
.. _Further_formatting_information:
https://numpydoc.readthedocs.io/en/latest/format.html
Notes
-----
The content inside the section should be indented.
Parameters
----------
p_arg1 : str
Explanation of the first parameter.
p_arg2 : bool
Explanation of the second parameter. The default is True.
Attributes
----------
C_MY_CONSTANT = 'My static value'
Explanation of the public constant C_MY_CONSTANT.
"""

pass





## -------------------------------------------------------------------------------------------------
## -------------------------------------------------------------------------------------------------
class AnomalyPrediction (Event):
"""
...
"""

pass
Empty file.
31 changes: 31 additions & 0 deletions src/mlpro/oa/streams/tasks/anomalypredictors/tsf/ad_based.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## -------------------------------------------------------------------------------------------------
## -- Project : MLPro - The integrative middleware framework for standardized machine learning
## -- Package : mlpro.oa.streams.tasks.anomalypredictors
## -- Module : basics.py
## -------------------------------------------------------------------------------------------------
## -- History :
## -- yyyy-mm-dd Ver. Auth. Description
## -- 2024-06-04 0.0.0 DA/DS Creation
## -- 2024-08-23 0.1.0 DA/DS Creation
## -------------------------------------------------------------------------------------------------

"""
Ver. 0.1.0 (2024-08-23)
This module provides basic templates for online anomaly prediction in MLPro.
"""


from mlpro.oa.streams.tasks.anomalypredictors.tsf.basics import AnomalyPredictorTSF



## -------------------------------------------------------------------------------------------------
## -------------------------------------------------------------------------------------------------
class AnomalyPredictorAD (AnomalyPredictorTSF):
"""
...
"""

pass
59 changes: 59 additions & 0 deletions src/mlpro/oa/streams/tasks/anomalypredictors/tsf/basics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
## -------------------------------------------------------------------------------------------------
## -- Project : MLPro - The integrative middleware framework for standardized machine learning
## -- Package : mlpro.oa.streams.tasks.anomalypredictors
## -- Module : basics.py
## -------------------------------------------------------------------------------------------------
## -- History :
## -- yyyy-mm-dd Ver. Auth. Description
## -- 2024-06-04 0.0.0 DA/DS Creation
## -- 2024-08-23 0.1.0 DA/DS Creation
## -------------------------------------------------------------------------------------------------

"""
Ver. 0.1.0 (2024-08-23)
This module provides basic templates for online anomaly prediction in MLPro.
"""


from mlpro.bf.math import Function
from mlpro.oa.streams.tasks.anomalypredictors import AnomalyPredictor, AnomalyPrediction
from mlpro.sl import SLAdaptiveFunction



## -------------------------------------------------------------------------------------------------
## -------------------------------------------------------------------------------------------------
class TimeSeriesForcaster (Function):
"""
...
"""

pass





## -------------------------------------------------------------------------------------------------
## -------------------------------------------------------------------------------------------------
class OATimeSeriesForcaster (TimeSeriesForcaster, SLAdaptiveFunction):
"""
...
"""

pass





## -------------------------------------------------------------------------------------------------
## -------------------------------------------------------------------------------------------------
class AnomalyPredictorTSF (AnomalyPredictor):
"""
...
"""

pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
## -------------------------------------------------------------------------------------------------
## -- Project : MLPro - The integrative middleware framework for standardized machine learning
## -- Package : mlpro.oa.streams.tasks.anomalypredictors
## -- Module : basics.py
## -------------------------------------------------------------------------------------------------
## -- History :
## -- yyyy-mm-dd Ver. Auth. Description
## -- 2024-06-04 0.0.0 DA/DS Creation
## -- 2024-08-23 0.1.0 DA/DS Creation
## -------------------------------------------------------------------------------------------------

"""
Ver. 0.1.0 (2024-08-23)
This module provides basic templates for online anomaly prediction in MLPro.
"""


from mlpro.oa.streams.tasks.anomalypredictors.tsf.basics import OATimeSeriesForcaster



## -------------------------------------------------------------------------------------------------
## -------------------------------------------------------------------------------------------------
class MiniBatchManager:
"""
"""

pass





## -------------------------------------------------------------------------------------------------
## -------------------------------------------------------------------------------------------------
class OATimeSeriesForcasterMB (OATimeSeriesForcaster):
"""
...
"""

pass
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,24 @@
the screen following the run.
"""
from mlpro.bf.math import Event
from mlpro.bf.mt import Event
from mlpro.bf.streams.streams import *
from mlpro.bf.various import Log
from mlpro.oa.streams import *
from mlpro_int_river.wrappers.clusteranalyzers.kmeans import WrRiverKMeans2MLPro
from mlpro.oa.streams.tasks.anomalydetectors.cb_detectors.drift_detector import ClusterDriftDetector
from mlpro.oa.streams.tasks.anomalypredictors.tsf.ad_based import AnomalyPredictorAD




class DevindisPredictor (AnomalyPredictorAD):

def _adapt_on_event(self, p_event_id: str, p_event_object: Event) -> bool:

# Set breakpoint here...
pass



Expand Down Expand Up @@ -102,10 +115,11 @@ def _setup(self, p_mode, p_ada: bool, p_visualize: bool, p_logging):
workflow.add_task(p_task=task_anomaly_detector, p_pred_tasks=[task_clusterer])

# Anomaly Predictor
task_anomaly_predictor = ClusterDriftDetector(p_visualize=p_visualize,
p_logging=p_logging)

workflow.adapt_on_event(p_task=task_anomaly_detector)
task_anomaly_predictor = DevindisPredictor( p_visualize=p_visualize,
p_logging=p_logging)

task_anomaly_detector.register_event_handler( p_event_id = 'Anomaly',
p_event_handler = task_anomaly_predictor.adapt_on_event )

# 1.3 Return stream and workflow
return stream, workflow
Expand Down

0 comments on commit 9add598

Please sign in to comment.