]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
fix(qav3): pad not evenly shapped chunks
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 19 Feb 2025 22:27:42 +0000 (23:27 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 19 Feb 2025 22:27:42 +0000 (23:27 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
quickadapter/user_data/freqaimodels/LightGBMRegressorQuickAdapterV35.py
quickadapter/user_data/freqaimodels/XGBoostRegressorQuickAdapterV35.py

index dc09d623d0ae981978c1c38de07ec2fc5190456c..6cf2c9605f8cba8628ee36a5d6146c5e9aced194 100644 (file)
@@ -588,6 +588,25 @@ def period_objective(
         y_pred.iloc[i : i + label_period_candles]
         for i in range(0, len(y_pred), label_period_candles)
     ]
+    max_chunk_length = max(len(chunk) for chunk in y_test + y_pred)
+    y_test = [
+        np.pad(
+            chunk,
+            (0, max_chunk_length - len(chunk)),
+            mode="constant",
+            constant_values=np.nan,
+        )
+        for chunk in y_test
+    ]
+    y_pred = [
+        np.pad(
+            chunk,
+            (0, max_chunk_length - len(chunk)),
+            mode="constant",
+            constant_values=np.nan,
+        )
+        for chunk in y_pred
+    ]
 
     error = sklearn.metrics.root_mean_squared_error(y_test, y_pred)
 
index 48d2e6bf068fbd9b8b46ca236795944643cc9090..3709690a18d08ea908e846fc370069a2235d0ace 100644 (file)
@@ -592,6 +592,25 @@ def period_objective(
         y_pred.iloc[i : i + label_period_candles]
         for i in range(0, len(y_pred), label_period_candles)
     ]
+    max_chunk_length = max(len(chunk) for chunk in y_test + y_pred)
+    y_test = [
+        np.pad(
+            chunk,
+            (0, max_chunk_length - len(chunk)),
+            mode="constant",
+            constant_values=np.nan,
+        )
+        for chunk in y_test
+    ]
+    y_pred = [
+        np.pad(
+            chunk,
+            (0, max_chunk_length - len(chunk)),
+            mode="constant",
+            constant_values=np.nan,
+        )
+        for chunk in y_pred
+    ]
 
     error = sklearn.metrics.root_mean_squared_error(y_test, y_pred)