You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
711 B
23 lines
711 B
![]()
6 years ago
|
import config
|
||
![]()
6 years ago
|
import detectors
|
||
![]()
6 years ago
|
import logging
|
||
6 years ago
|
import pandas as pd
|
||
6 years ago
|
from typing import Optional
|
||
|
from models import AnalyticUnitCache
|
||
![]()
6 years ago
|
|
||
|
|
||
6 years ago
|
logger = logging.getLogger('AnalyticUnitWorker')
|
||
![]()
6 years ago
|
|
||
![]()
6 years ago
|
|
||
6 years ago
|
class AnalyticUnitWorker:
|
||
|
|
||
6 years ago
|
def __init__(self, analytic_unit_id: str, detector: detectors.Detector):
|
||
|
self.analytic_unit_id = analytic_unit_id
|
||
|
self.detector = detector
|
||
![]()
6 years ago
|
|
||
6 years ago
|
async def do_learn(self, segments: list, data: pd.DataFrame, cache: Optional[AnalyticUnitCache]) -> AnalyticUnitCache:
|
||
6 years ago
|
return await self.detector.train(data, segments, cache)
|
||
![]()
6 years ago
|
|
||
6 years ago
|
async def do_predict(self, data: pd.DataFrame, cache: Optional[AnalyticUnitCache]) -> dict:
|
||
6 years ago
|
return await self.detector.predict(data, cache)
|