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.

31 lines
806 B

from abc import ABC, abstractmethod
from pandas import DataFrame
import pickle
class Model(ABC):
def __init__(self):
"""
Variables which are obtained as a result of fit() method
should be stored in self.state dict
in order to be saved in model file
"""
self.state = {}
self.segments = []
@abstractmethod
async def fit(self, dataframe: DataFrame, segments: list):
pass
@abstractmethod
async def predict(self, dataframe: DataFrame) -> list:
pass
def save(self, model_filename: str):
with open(model_filename, 'wb') as file:
pickle.dump(self.state, file)
def load(self, model_filename: str):
with open(model_filename, 'rb') as f:
self.state = pickle.load(f)