]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
refactor: cleanup optuna best trial check
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 9 Apr 2025 19:32:43 +0000 (21:32 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 9 Apr 2025 19:32:43 +0000 (21:32 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
ReforceXY/user_data/freqaimodels/ReforceXY.py
quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py

index b4c06ddb3609f9c60d9ef9df96e737628b080d9a..64c4be17f754bcf5ee8da74e3fc52f62a871e789 100644 (file)
@@ -506,11 +506,11 @@ class ReforceXY(BaseReinforcementLearningModel):
         return storage
 
     @staticmethod
-    def study_has_best_trial_params(study: Optional[Study]) -> bool:
+    def study_has_best_trial(study: Optional[Study]) -> bool:
         if study is None:
             return False
         try:
-            _ = study.best_trial.params
+            _ = study.best_trial
             return True
         # file backend storage raises KeyError
         except KeyError:
@@ -576,9 +576,9 @@ class ReforceXY(BaseReinforcementLearningModel):
             )
             hyperopt_failed = True
         time_spent = time.time() - start
-        if ReforceXY.study_has_best_trial_params(study) is False:
+        if ReforceXY.study_has_best_trial(study) is False:
             logger.error(
-                f"Hyperopt {study_name} failed ({time_spent:.2f} secs): no study best trial params found"
+                f"Hyperopt {study_name} failed ({time_spent:.2f} secs): no study best trial found"
             )
             hyperopt_failed = True
 
index e6115169daa936904d977039eb3089d7b4266fd9..7a07a553d8b8908e9986003e06c92cbcd95564c5 100644 (file)
@@ -44,7 +44,7 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
     https://github.com/sponsors/robcaulk
     """
 
-    version = "3.7.4"
+    version = "3.7.5"
 
     @cached_property
     def _optuna_config(self) -> dict:
@@ -470,9 +470,9 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
 
         time_spent = time.time() - start_time
         if is_study_multi_objective is False:
-            if not QuickAdapterRegressorV3.optuna_study_has_best_params(study):
+            if not QuickAdapterRegressorV3.optuna_study_has_best_trial(study):
                 logger.error(
-                    f"Optuna {pair} {namespace} {objective_type} hyperopt failed ({time_spent:.2f} secs): no study best params found"
+                    f"Optuna {pair} {namespace} {objective_type} hyperopt failed ({time_spent:.2f} secs): no study best trial found"
                 )
                 return
             self.set_optuna_rmse(pair, namespace, study.best_value)
@@ -614,11 +614,11 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
         return study
 
     @staticmethod
-    def optuna_study_has_best_params(study: Optional[optuna.study.Study]) -> bool:
+    def optuna_study_has_best_trial(study: Optional[optuna.study.Study]) -> bool:
         if study is None:
             return False
         try:
-            _ = study.best_params
+            _ = study.best_trial
             return True
         # file backend storage raises KeyError
         except KeyError: