diff --git a/analytics/detectors/pattern_detector.py b/analytics/detectors/pattern_detector.py index 31ecec6..1dfa211 100644 --- a/analytics/detectors/pattern_detector.py +++ b/analytics/detectors/pattern_detector.py @@ -23,6 +23,8 @@ def resolve_model_by_pattern(pattern: str) -> models.Model: return models.StepModel() if pattern == 'jump': return models.JumpModel() + if pattern == 'custom': + return models.CustomModel() raise ValueError('Unknown pattern "%s"' % pattern) diff --git a/analytics/models/__init__.py b/analytics/models/__init__.py index 7989a6c..b6ffc10 100644 --- a/analytics/models/__init__.py +++ b/analytics/models/__init__.py @@ -2,3 +2,4 @@ from models.model import Model from models.step_model import StepModel from models.peaks_model import PeaksModel from models.jump_model import JumpModel +from models.custom_model import CustomModel diff --git a/analytics/models/custom_model.py b/analytics/models/custom_model.py new file mode 100644 index 0000000..8d7a60b --- /dev/null +++ b/analytics/models/custom_model.py @@ -0,0 +1,17 @@ +from models import Model +import utils + +# Paste your model here: +class CustomModel(Model): + + def __init__(self): + super() + # Use self.state to store results of your learning + # It will be saved in filesystem and loaded after server restart + self.state = {} + + async def fit(self, dataframe, segments): + pass + + async def predict(self, dataframe): + return []