Refractor(Main Pipeline): Refractored the two main steps and the data processing. (#156)

* refr: Took out main primary and secondary loops and data processing.

* feat: Tidied the code up.

* feat: Saving models and results now works in a type safe way.

* fix: There was error in the saving function.

* chore: Took out some remaining comments.

* fix: Fixed the previous data checking process.

* feat: Fixed model selection method. I will continue the inference after we merged.

Co-authored-by: Daniel Szemerey <szemereydaniel@gmail.com>
This commit is contained in:
Daniel Szemerey
2022-01-12 23:10:18 +01:00
committed by GitHub
co-authored by Daniel Szemerey
parent c611481eb6
commit 3084f5e271
9 changed files with 277 additions and 161 deletions
+4 -1
View File
@@ -5,6 +5,7 @@ from feature_selection.feature_selection import select_features
import pandas as pd
from models.model_map import default_feature_selector_regression, default_feature_selector_classification
from models.base import Model
from utils.encapsulation import Single_Model
def train_meta_labeling_model(
@@ -18,8 +19,9 @@ def train_meta_labeling_model(
model_config: dict,
training_config: dict,
model_suffix: str
) -> tuple[pd.Series, pd.Series, pd.DataFrame, dict]:
) -> tuple[pd.Series, pd.Series, pd.DataFrame, list[Single_Model]]:
discretize = discretize_threeway_threshold(0.33)
discretized_predictions = input_predictions.apply(discretize)
meta_y: pd.Series = pd.concat([discretized_predictions, y], axis=1).apply(equal_except_nan, axis = 1)
@@ -67,5 +69,6 @@ def train_meta_labeling_model(
discretize=False
)
meta_result.rename("model_" + target_asset + "_" + model_suffix, inplace=True)
return meta_result, avg_predictions_with_sizing, meta_probabilities, all_models_single_asset