refactor(Evaluate): print out accuracy, f1, etc. for the final & meta predictions, separated out evaluation step (#228)

* refactor(Evaluate): print out accuracy, f1, etc. for the final & meta predictions, separated out evaluation step

* fix(Linter): ran

* fix(Tests): syntax change

* fix(Inference): runs now again

* fix(Linter): ran
This commit is contained in:
Mark Aron Szulyovszky
2022-03-03 17:40:17 +01:00
committed by GitHub
parent 75157c6285
commit 567cd5e9f0
13 changed files with 153 additions and 118 deletions
+30
View File
@@ -1,6 +1,8 @@
import pandas as pd
from data_loader.types import ForwardReturnSeries
from labeling.types import EventsDataFrame
from typing import Callable
import numpy as np
def create_forward_returns(series: pd.Series, period: int) -> ForwardReturnSeries:
@@ -22,3 +24,31 @@ def purge_overlapping_events(events: EventsDataFrame) -> EventsDataFrame:
last_event_end = row["end"]
events.drop(indicies_to_remove, inplace=True)
return events
def discretize_binary(x):
return 1 if x > 0 else -1
def discretize_binary_zero_one(x):
return 1 if x > 0 else 0
def discretize_threeway(x):
return 0 if x == 0 else 1 if x > 0 else -1
def discretize_threeway_threshold(threshold: float) -> Callable:
def discretize(current_value):
lower_threshold = -threshold
upper_threshold = threshold
if np.isnan(current_value):
return np.nan
elif current_value <= lower_threshold:
return -1
elif current_value > lower_threshold and current_value < upper_threshold:
return 0
else:
return 1
return discretize