add min max strategies and data augmentation training
This commit is contained in:
@@ -870,11 +870,25 @@ class FreqaiDataKitchen:
|
||||
"""
|
||||
Add noise to train features to reduce the risk of overfitting.
|
||||
"""
|
||||
mu = 0 # no shift
|
||||
sigma = self.freqai_config["feature_parameters"]["noise_standard_deviation"]
|
||||
compute_df = self.data_dictionary['train_features']
|
||||
noise = np.random.normal(mu, sigma, [compute_df.shape[0], compute_df.shape[1]])
|
||||
self.data_dictionary['train_features'] += noise
|
||||
da = self.freqai_config["feature_parameters"]["data_augment"]
|
||||
X = self.data_dictionary['train_features']
|
||||
y = self.data_dictionary['train_labels']
|
||||
da_type = da.get("type", "std")
|
||||
if da_type == "std":
|
||||
# generate alpha values of 0-mean and 1-std
|
||||
alpha = np.random.randn(*X.shape)
|
||||
scale = da.get("vaue", 0.01)
|
||||
Xaugmented = X + alpha * scale * X.std(0)[None, :]
|
||||
X = np.vstack((X, Xaugmented))
|
||||
y = y.append(y)
|
||||
self.data_dictionary['train_features'] = X
|
||||
self.data_dictionary['train_labels'] = y
|
||||
elif da_type == "constant":
|
||||
mu = 0 # no shift
|
||||
sigma = self.freqai_config["feature_parameters"]["data_augment"]["value"]
|
||||
compute_df = self.data_dictionary['train_features']
|
||||
noise = np.random.normal(mu, sigma, [compute_df.shape[0], compute_df.shape[1]])
|
||||
self.data_dictionary['train_features'] += noise
|
||||
return
|
||||
|
||||
def find_features(self, dataframe: DataFrame) -> None:
|
||||
@@ -1217,6 +1231,7 @@ class FreqaiDataKitchen:
|
||||
|
||||
for key in self.label_list:
|
||||
if dataframe[key].dtype == object:
|
||||
# TODO: make sure the `dataframe[key].dropna().unique()` are objet type too!
|
||||
self.unique_classes[key] = dataframe[key].dropna().unique()
|
||||
|
||||
if self.unique_classes:
|
||||
|
Reference in New Issue
Block a user