feat: ensure full backwards compatibility

This commit is contained in:
robcaulk 2023-06-16 13:20:35 +02:00
parent 75ec19062c
commit 72101f059d
2 changed files with 27 additions and 7 deletions

View File

@ -962,8 +962,7 @@ class FreqaiDataKitchen:
" This can be achieved by following the migration guide at "
f"{ft}/strategy_migration/#freqai-new-data-pipeline "
"We added a basic pipeline for you, but this will be removed "
"in a future version.\n"
"This version does not include any outlier configurations")
"in a future version.")
return data_dictionary
@ -977,11 +976,8 @@ class FreqaiDataKitchen:
" This can be achieved by following the migration guide at "
f"{ft}/strategy_migration/#freqai-new-data-pipeline "
"We added a basic pipeline for you, but this will be removed "
"in a future version.\n"
"This version does not include any outlier configurations")
"in a future version.")
pred_df, _, _ = self.label_pipeline.inverse_transform(df)
self.DI_values = np.zeros(len(pred_df.index))
self.do_predict = np.ones(len(pred_df.index))
return pred_df

View File

@ -979,6 +979,23 @@ class IFreqaiModel(ABC):
" This can be achieved by following the migration guide at "
f"{DOCS_LINK}/strategy_migration/#freqai-new-data-pipeline")
dk.feature_pipeline = self.define_data_pipeline(threads=dk.thread_count)
dd = dk.data_dictionary
(dd["train_features"],
dd["train_labels"],
dd["train_weights"]) = dk.feature_pipeline.fit_transform(dd["train_features"],
dd["train_labels"],
dd["train_weights"])
(dd["test_features"],
dd["test_labels"],
dd["test_weights"]) = dk.feature_pipeline.transform(dd["test_features"],
dd["test_labels"],
dd["test_weights"])
dk.label_pipeline = self.define_label_pipeline(threads=dk.thread_count)
dd["train_labels"], _, _ = dk.label_pipeline.fit_transform(dd["train_labels"])
dd["test_labels"], _, _ = dk.label_pipeline.transform(dd["test_labels"])
return
def data_cleaning_predict(self, dk: FreqaiDataKitchen, pair: str):
@ -989,5 +1006,12 @@ class IFreqaiModel(ABC):
" data pipeline. Please update your model to use the new data pipeline."
" This can be achieved by following the migration guide at "
f"{DOCS_LINK}/strategy_migration/#freqai-new-data-pipeline")
dk.label_pipeline = self.define_data_pipeline(threads=dk.thread_count)
dd = dk.data_dictionary
dd["predict_features"], outliers, _ = dk.feature_pipeline.transform(
dd["predict_features"], outlier_check=True)
if self.freqai_info.get("DI_threshold", 0) > 0:
dk.DI_values = dk.feature_pipeline["di"].di_values
else:
dk.DI_values = np.zeros(len(outliers.index))
dk.do_predict = outliers.to_numpy()
return