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.

29 lines
693 B

import utils
from abc import ABC, abstractmethod
from pandas import DataFrame
from typing import Optional
AnalyticUnitCache = dict
class Model(ABC):
@abstractmethod
def fit(self, dataframe: DataFrame, segments: list, cache: Optional[AnalyticUnitCache]) -> AnalyticUnitCache:
pass
@abstractmethod
def do_predict(self, dataframe: DataFrame) -> list:
pass
def predict(self, dataframe: DataFrame, cache: Optional[AnalyticUnitCache]) -> dict:
if type(cache) is AnalyticUnitCache:
self.state = cache
result = self.do_predict(dataframe)
return {
'segments': result,
'cache': self.state
}