add shuffle_after_split option

This commit is contained in:
robcaulk
2022-12-16 11:20:37 +01:00
parent 581a5296cc
commit c9bc91c75b
2 changed files with 25 additions and 9 deletions

View File

@@ -1,5 +1,6 @@
import copy
import logging
import random
import shutil
from datetime import datetime, timezone
from math import cos, sin
@@ -168,6 +169,19 @@ class FreqaiDataKitchen:
train_labels = labels
train_weights = weights
if feat_dict.get("shuffle_after_split", False):
rint1 = random.randint(0, 100)
rint2 = random.randint(0, 100)
train_features = train_features.sample(
frac=1, random_state=rint1).reset_index(drop=True)
train_labels = train_labels.sample(frac=1, random_state=rint1).reset_index(drop=True)
train_weights = pd.DataFrame(train_weights).sample(
frac=1, random_state=rint1).reset_index(drop=True).to_numpy()[:, 0]
test_features = test_features.sample(frac=1, random_state=rint2).reset_index(drop=True)
test_labels = test_labels.sample(frac=1, random_state=rint2).reset_index(drop=True)
test_weights = pd.DataFrame(test_weights).sample(
frac=1, random_state=rint2).reset_index(drop=True).to_numpy()[:, 0]
# Simplest way to reverse the order of training and test data:
if self.freqai_config['feature_parameters'].get('reverse_train_test_order', False):
return self.build_data_dictionary(