]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
perf(qav3): properly size optuna search space
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 6 Feb 2025 02:08:22 +0000 (03:08 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 6 Feb 2025 02:08:22 +0000 (03:08 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
quickadapter/user_data/config-template.json
quickadapter/user_data/freqaimodels/LightGBMRegressorQuickAdapterV35.py
quickadapter/user_data/freqaimodels/XGBoostRegressorQuickAdapterV35.py

index 9fef5948db6dcc8ed6aba85b90dec491e6a4f138..b28f087d3e282e84f17552fd39e3e7499792ba06 100644 (file)
     "optuna_hyperopt_trials": 36,
     "optuna_hyperopt_timeout": 3600,
     "optuna_hyperopt_jobs": 6,
-    "optuna_hyperopt_candles_step": 100,
+    "optuna_hyperopt_candles_step": 10,
     "extra_returns_per_train": {
       "DI_value_param1": 0,
       "DI_value_param2": 0,
index a8ab0d6206b9fa22564236ae3a8519f34ae4396a..65f6b166233501b46ba1fa37e68ed723f93dbc4a 100644 (file)
@@ -231,15 +231,19 @@ def objective(
     candles_step,
     params,
 ):
+    if (len(X) != len(y)) or (len(X) != len(train_weights)):
+        raise ValueError("Training sets must have the same length")
+    if (len(X_test) != len(y_test)) or (len(X_test) != len(test_weights)):
+        raise ValueError("Test sets must have the same length")
     train_window = trial.suggest_int(
-        "train_period_candles", 1152, 17280, step=candles_step
+        "train_period_candles", 0, len(X), step=candles_step
     )
     X = X.tail(train_window)
     y = y.tail(train_window)
     train_weights = train_weights[-train_window:]
 
     test_window = trial.suggest_int(
-        "test_period_candles", 1152, 17280, step=candles_step
+        "test_period_candles", 0, len(X_test), step=candles_step
     )
     X_test = X_test.tail(test_window)
     y_test = y_test.tail(test_window)
index 6017b0ab3c6fa48d1f6ad2b9105650d3173d5544..6a2e8203e8db43a0e93ceb9af3a97c20344c2dc0 100644 (file)
@@ -231,15 +231,19 @@ def objective(
     candles_step,
     params,
 ):
+    if (len(X) != len(y)) or (len(X) != len(train_weights)):
+        raise ValueError("Training sets must have the same length")
+    if (len(X_test) != len(y_test)) or (len(X_test) != len(test_weights)):
+        raise ValueError("Test sets must have the same length")
     train_window = trial.suggest_int(
-        "train_period_candles", 1152, 17280, step=candles_step
+        "train_period_candles", 0, len(X), step=candles_step
     )
     X = X.tail(train_window)
     y = y.tail(train_window)
     train_weights = train_weights[-train_window:]
 
     test_window = trial.suggest_int(
-        "test_period_candles", 1152, 17280, step=candles_step
+        "test_period_candles", 0, len(X_test), step=candles_step
     )
     X_test = X_test.tail(test_window)
     y_test = y_test.tail(test_window)