2022-01-13 09:21:07 +01:00
|
|
|
from __future__ import annotations
|
|
|
|
|
import pandas as pd
|
|
|
|
|
from models.base import Model
|
2022-01-23 11:38:40 +01:00
|
|
|
from typing import Optional, Union
|
2022-01-13 09:21:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class Reporting:
|
|
|
|
|
def __init__(self):
|
|
|
|
|
self.results: pd.DataFrame = pd.DataFrame()
|
|
|
|
|
self.all_predictions: pd.DataFrame = pd.DataFrame()
|
|
|
|
|
self.all_probabilities: pd.DataFrame = pd.DataFrame()
|
2022-01-23 11:38:40 +01:00
|
|
|
self.asset: Reporting.Asset
|
2022-01-13 09:21:07 +01:00
|
|
|
|
2022-01-23 11:38:40 +01:00
|
|
|
def get_results(self) -> tuple[pd.DataFrame, pd.DataFrame, pd.DataFrame, Reporting.Asset]:
|
|
|
|
|
return self.results, self.all_predictions, self.all_probabilities, self.asset
|
2022-01-13 09:21:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class Single_Model:
|
2022-01-23 11:38:40 +01:00
|
|
|
def __init__(self, model_name: str, model_over_time: pd.Series, transformations_over_time: list[pd.Series]):
|
2022-01-13 09:21:07 +01:00
|
|
|
self.model_name: str = model_name
|
2022-01-23 11:38:40 +01:00
|
|
|
self.model_over_time: pd.Series = model_over_time
|
|
|
|
|
self.transformations_over_time: list[pd.Series] = transformations_over_time
|
2022-01-13 09:21:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class Training_Step:
|
|
|
|
|
def __init__(self, level: str):
|
|
|
|
|
self.level: str = level
|
|
|
|
|
self.base: list[Reporting.Single_Model] = []
|
|
|
|
|
self.metalabeling: list[list[Reporting.Single_Model]] = []
|
2022-01-14 10:34:28 +01:00
|
|
|
|
2022-01-23 11:38:40 +01:00
|
|
|
def get_base(self) -> list[tuple[str, pd.Series, list[pd.Series]]]:
|
|
|
|
|
return [(x.model_name, x.model_over_time, x.transformations_over_time) for x in self.base ]
|
2022-01-13 09:21:07 +01:00
|
|
|
|
2022-01-23 11:38:40 +01:00
|
|
|
def get_metalabeling(self) -> dict:
|
|
|
|
|
structured_dict = dict()
|
|
|
|
|
for i, model in enumerate(self.base):
|
|
|
|
|
structured_dict[model.model_name] = [(x.model_name, x.model_over_time, x.transformations_over_time) for x in self.metalabeling[i]]
|
|
|
|
|
return structured_dict
|
2022-01-13 09:21:07 +01:00
|
|
|
|
|
|
|
|
class Asset():
|
|
|
|
|
def __init__(self, ticker: str, primary: Reporting.Training_Step, secondary: Reporting.Training_Step):
|
|
|
|
|
self.name: str = ticker
|
|
|
|
|
self.primary: Reporting.Training_Step = primary
|
|
|
|
|
self.secondary: Reporting.Training_Step = secondary
|