From: Jérôme Benoit Date: Sat, 15 Feb 2025 21:01:40 +0000 (+0100) Subject: fix(qav3): refine optuna loaded study validation test X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=f21427bb673b9af7659e260d0167dca81fd8fd22;p=freqai-strategies.git fix(qav3): refine optuna loaded study validation test Signed-off-by: Jérôme Benoit --- diff --git a/quickadapter/user_data/freqaimodels/LightGBMRegressorQuickAdapterV35.py b/quickadapter/user_data/freqaimodels/LightGBMRegressorQuickAdapterV35.py index 8820b80..04152a8 100644 --- a/quickadapter/user_data/freqaimodels/LightGBMRegressorQuickAdapterV35.py +++ b/quickadapter/user_data/freqaimodels/LightGBMRegressorQuickAdapterV35.py @@ -394,14 +394,8 @@ class LightGBMRegressorQuickAdapterV35(BaseRegressionModel): if not study: return False try: - # Check if there are completed trials - if len(study.trials) == 0: - return False - - # Check if best_params exists (raises ValueError if no trials succeeded) - _ = study.best_params - return True - except ValueError: + _ = study.trials + except KeyError: return False diff --git a/quickadapter/user_data/freqaimodels/XGBoostRegressorQuickAdapterV35.py b/quickadapter/user_data/freqaimodels/XGBoostRegressorQuickAdapterV35.py index fa3fedf..0872136 100644 --- a/quickadapter/user_data/freqaimodels/XGBoostRegressorQuickAdapterV35.py +++ b/quickadapter/user_data/freqaimodels/XGBoostRegressorQuickAdapterV35.py @@ -395,14 +395,8 @@ class XGBoostRegressorQuickAdapterV35(BaseRegressionModel): if not study: return False try: - # Check if there are completed trials - if len(study.trials) == 0: - return False - - # Check if best_params exists (raises ValueError if no trials succeeded) - _ = study.best_params - return True - except ValueError: + _ = study.trials + except KeyError: return False