improve flexibility of user defined prediction dataframe

This commit is contained in:
Robert Caulk
2022-08-06 13:51:19 +02:00
parent fdc82f8302
commit c172ce1011
6 changed files with 42 additions and 31 deletions

View File

@@ -342,7 +342,7 @@ class FreqaiDataKitchen:
:df: Dataframe of predictions to be denormalized
"""
for label in self.label_list:
for label in df.columns:
if df[label].dtype == object:
continue
df[label] = (
@@ -716,14 +716,16 @@ class FreqaiDataKitchen:
weights = np.exp(-np.arange(num_weights) / (wfactor * num_weights))[::-1]
return weights
def append_predictions(self, predictions, do_predict, len_dataframe):
def append_predictions(self, predictions: DataFrame, do_predict: npt.ArrayLike) -> None:
"""
Append backtest prediction from current backtest period to all previous periods
"""
append_df = DataFrame()
for label in self.label_list:
for label in predictions.columns:
append_df[label] = predictions[label]
if append_df[label].dtype == object:
continue
append_df[f"{label}_mean"] = self.data["labels_mean"][label]
append_df[f"{label}_std"] = self.data["labels_std"][label]
@@ -1009,7 +1011,7 @@ class FreqaiDataKitchen:
import scipy as spy
self.data["labels_mean"], self.data["labels_std"] = {}, {}
for label in self.label_list:
for label in self.data_dictionary["train_labels"].columns:
if self.data_dictionary["train_labels"][label].dtype == object:
continue
f = spy.stats.norm.fit(self.data_dictionary["train_labels"][label])