From 4c16156b779a7f8ee6d8a0545c297c58c2e69782 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Wed, 19 Feb 2025 23:27:42 +0100 Subject: [PATCH] fix(qav3): pad not evenly shapped chunks MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../LightGBMRegressorQuickAdapterV35.py | 19 +++++++++++++++++++ .../XGBoostRegressorQuickAdapterV35.py | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/quickadapter/user_data/freqaimodels/LightGBMRegressorQuickAdapterV35.py b/quickadapter/user_data/freqaimodels/LightGBMRegressorQuickAdapterV35.py index dc09d62..6cf2c96 100644 --- a/quickadapter/user_data/freqaimodels/LightGBMRegressorQuickAdapterV35.py +++ b/quickadapter/user_data/freqaimodels/LightGBMRegressorQuickAdapterV35.py @@ -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) diff --git a/quickadapter/user_data/freqaimodels/XGBoostRegressorQuickAdapterV35.py b/quickadapter/user_data/freqaimodels/XGBoostRegressorQuickAdapterV35.py index 48d2e6b..3709690 100644 --- a/quickadapter/user_data/freqaimodels/XGBoostRegressorQuickAdapterV35.py +++ b/quickadapter/user_data/freqaimodels/XGBoostRegressorQuickAdapterV35.py @@ -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) -- 2.43.0