2022-01-04 11:44:35 +01:00
|
|
|
from __future__ import annotations
|
2022-01-05 12:25:03 +01:00
|
|
|
from typing import Literal, Optional, Union
|
2022-01-04 11:44:35 +01:00
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
|
import numpy as np
|
2021-12-21 10:30:09 +01:00
|
|
|
|
2022-01-12 23:10:18 +01:00
|
|
|
# import numpy as np
|
2022-01-05 12:25:03 +01:00
|
|
|
|
2021-12-21 15:57:08 +01:00
|
|
|
class Model(ABC):
|
2021-12-21 10:30:09 +01:00
|
|
|
|
|
|
|
|
data_scaling: Literal["scaled", "unscaled"]
|
2021-12-27 21:59:22 +01:00
|
|
|
feature_selection: Literal["on", "off"]
|
2021-12-21 10:30:09 +01:00
|
|
|
# data_format: Literal["wide", "narrow"]
|
|
|
|
|
only_column: Optional[str]
|
2021-12-27 21:59:22 +01:00
|
|
|
model_type: Literal['ml', 'static']
|
2022-01-04 11:44:35 +01:00
|
|
|
predict_window_size: Literal['single_timestamp', 'window_size']
|
2021-12-21 10:30:09 +01:00
|
|
|
|
2021-12-21 15:57:08 +01:00
|
|
|
@abstractmethod
|
2022-01-04 11:44:35 +01:00
|
|
|
def fit(self, X: np.ndarray, y: np.ndarray) -> None:
|
|
|
|
|
raise NotImplementedError
|
2021-12-21 10:30:09 +01:00
|
|
|
|
2021-12-21 15:57:08 +01:00
|
|
|
@abstractmethod
|
2022-01-05 12:25:03 +01:00
|
|
|
def predict(self, X: np.ndarray) -> tuple[float, np.ndarray]:
|
2022-01-04 11:44:35 +01:00
|
|
|
raise NotImplementedError
|
2021-12-21 10:30:09 +01:00
|
|
|
|
2021-12-21 15:57:08 +01:00
|
|
|
@abstractmethod
|
2022-01-04 11:44:35 +01:00
|
|
|
def clone(self) -> Model:
|
|
|
|
|
raise NotImplementedError
|
|
|
|
|
|
2022-01-05 12:25:03 +01:00
|
|
|
@abstractmethod
|
2022-01-04 11:44:35 +01:00
|
|
|
def get_name(self) -> str:
|
|
|
|
|
raise NotImplementedError
|
2022-01-05 12:25:03 +01:00
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def initialize_network(self, input_dim:int, output_dim:int):
|
|
|
|
|
pass
|
2021-12-21 10:30:09 +01:00
|
|
|
|
2022-01-04 11:44:35 +01:00
|
|
|
|
2022-01-05 12:25:03 +01:00
|
|
|
|
|
|
|
|
|