Feat/freqai (#7105)
Vectorize weight setting, log training dates Co-authored-by: robcaulk <rob.caulk@gmail.com>
This commit is contained in:
parent
714d9534b6
commit
9c051958a6
@ -680,12 +680,9 @@ class FreqaiDataKitchen:
|
|||||||
Set weights so that recent data is more heavily weighted during
|
Set weights so that recent data is more heavily weighted during
|
||||||
training than older data.
|
training than older data.
|
||||||
"""
|
"""
|
||||||
|
wfactor = self.config["freqai"]["feature_parameters"]["weight_factor"]
|
||||||
weights = np.zeros(num_weights)
|
weights = np.exp(
|
||||||
for i in range(1, len(weights)):
|
- np.arange(num_weights) / (wfactor * num_weights))[::-1]
|
||||||
weights[len(weights) - i] = np.exp(
|
|
||||||
-i / (self.config["freqai"]["feature_parameters"]["weight_factor"] * num_weights)
|
|
||||||
)
|
|
||||||
return weights
|
return weights
|
||||||
|
|
||||||
def append_predictions(self, predictions, do_predict, len_dataframe):
|
def append_predictions(self, predictions, do_predict, len_dataframe):
|
||||||
|
@ -39,7 +39,7 @@ class BaseRegressionModel(IFreqaiModel):
|
|||||||
:model: Trained model which can be used to inference (self.predict)
|
:model: Trained model which can be used to inference (self.predict)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
logger.info("--------------------Starting training " f"{pair} --------------------")
|
logger.info("-------------------- Starting training " f"{pair} --------------------")
|
||||||
|
|
||||||
# filter the features requested by user in the configuration file and elegantly handle NaNs
|
# filter the features requested by user in the configuration file and elegantly handle NaNs
|
||||||
features_filtered, labels_filtered = dk.filter_features(
|
features_filtered, labels_filtered = dk.filter_features(
|
||||||
@ -49,6 +49,10 @@ class BaseRegressionModel(IFreqaiModel):
|
|||||||
training_filter=True,
|
training_filter=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
start_date = unfiltered_dataframe["date"].iloc[0].strftime("%Y-%m-%d")
|
||||||
|
end_date = unfiltered_dataframe["date"].iloc[-1].strftime("%Y-%m-%d")
|
||||||
|
logger.info(f"-------------------- Training on data from {start_date} to "
|
||||||
|
f"{end_date}--------------------")
|
||||||
# split data into train/test data.
|
# split data into train/test data.
|
||||||
data_dictionary = dk.make_train_test_datasets(features_filtered, labels_filtered)
|
data_dictionary = dk.make_train_test_datasets(features_filtered, labels_filtered)
|
||||||
if not self.freqai_info.get('fit_live_predictions', 0):
|
if not self.freqai_info.get('fit_live_predictions', 0):
|
||||||
|
Loading…
Reference in New Issue
Block a user