From: Jérôme Benoit Date: Fri, 21 Feb 2025 17:03:59 +0000 (+0100) Subject: refactor!: align file namespace X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=c7c78fd601f9f1193de9f8685cb1baec2c763418;p=freqai-strategies.git refactor!: align file namespace Signed-off-by: Jérôme Benoit --- diff --git a/ReforceXY/user_data/freqaimodels/ReforceXY.py b/ReforceXY/user_data/freqaimodels/ReforceXY.py index acd1d47..0d063da 100644 --- a/ReforceXY/user_data/freqaimodels/ReforceXY.py +++ b/ReforceXY/user_data/freqaimodels/ReforceXY.py @@ -339,15 +339,17 @@ class ReforceXY(BaseReinforcementLearningModel): logger.info("%s params: %s", self.model_type, model_params) if self.activate_tensorboard: - tb_path = Path(self.full_path / "tensorboard" / dk.pair.split("/")[0]) + tensorboard_log_path = Path( + self.full_path / "tensorboard" / dk.pair.split("/")[0] + ) else: - tb_path = None + tensorboard_log_path = None if dk.pair not in self.dd.model_dictionary or not self.continual_learning: model = self.MODELCLASS( self.policy_type, self.train_env, - tensorboard_log=tb_path, + tensorboard_log=tensorboard_log_path, **model_params, ) else: @@ -523,7 +525,7 @@ class ReforceXY(BaseReinforcementLearningModel): Save the best hyperparameters found during hyperparameter optimization """ best_params_path = Path( - self.full_path / f"{pair.split('/')[0]}_hyperopt_best_params.json" + self.full_path / f"hyperopt-best-params-{pair.split('/')[0]}.json" ) logger.info(f"{pair}: saving best params to %s JSON file", best_params_path) with best_params_path.open("w", encoding="utf-8") as write_file: @@ -534,7 +536,7 @@ class ReforceXY(BaseReinforcementLearningModel): Load the best hyperparameters found and saved during hyperparameter optimization """ best_params_path = Path( - self.full_path / f"{pair.split('/')[0]}_hyperopt_best_params.json" + self.full_path / f"hyperopt-best-params-{pair.split('/')[0]}.json" ) if best_params_path.is_file(): logger.info( @@ -563,9 +565,13 @@ class ReforceXY(BaseReinforcementLearningModel): params = {**self.model_training_parameters, **params} nan_encountered = False - tensorboard_log_path = Path( - self.full_path / "tensorboard" / dk.pair.split("/")[0] - ) + + if self.activate_tensorboard: + tensorboard_log_path = Path( + self.full_path / "tensorboard" / dk.pair.split("/")[0] + ) + else: + tensorboard_log_path = None logger.info( "------------ Hyperopt trial %d %s ------------", trial.number, dk.pair diff --git a/quickadapter/user_data/freqaimodels/LightGBMRegressorQuickAdapterV35.py b/quickadapter/user_data/freqaimodels/LightGBMRegressorQuickAdapterV35.py index b1f316c..f213dec 100644 --- a/quickadapter/user_data/freqaimodels/LightGBMRegressorQuickAdapterV35.py +++ b/quickadapter/user_data/freqaimodels/LightGBMRegressorQuickAdapterV35.py @@ -430,14 +430,14 @@ class LightGBMRegressorQuickAdapterV35(BaseRegressionModel): self, pair: str, namespace: str, best_params: Dict ) -> None: best_params_path = Path( - self.full_path / f"{pair.split('/')[0]}_optuna_{namespace}_best_params.json" + self.full_path / f"optuna-{namespace}-best-params-{pair.split('/')[0]}.json" ) with best_params_path.open("w", encoding="utf-8") as write_file: json.dump(best_params, write_file, indent=4) def optuna_load_best_params(self, pair: str, namespace: str) -> Dict | None: best_params_path = Path( - self.full_path / f"{pair.split('/')[0]}_optuna_{namespace}_best_params.json" + self.full_path / f"optuna-{namespace}-best-params-{pair.split('/')[0]}.json" ) if best_params_path.is_file(): with best_params_path.open("r", encoding="utf-8") as read_file: diff --git a/quickadapter/user_data/freqaimodels/XGBoostRegressorQuickAdapterV35.py b/quickadapter/user_data/freqaimodels/XGBoostRegressorQuickAdapterV35.py index caff5fc..8e4a3a2 100644 --- a/quickadapter/user_data/freqaimodels/XGBoostRegressorQuickAdapterV35.py +++ b/quickadapter/user_data/freqaimodels/XGBoostRegressorQuickAdapterV35.py @@ -431,14 +431,14 @@ class XGBoostRegressorQuickAdapterV35(BaseRegressionModel): self, pair: str, namespace: str, best_params: Dict ) -> None: best_params_path = Path( - self.full_path / f"{pair.split('/')[0]}_optuna_{namespace}_best_params.json" + self.full_path / f"optuna-{namespace}-best-params-{pair.split('/')[0]}.json" ) with best_params_path.open("w", encoding="utf-8") as write_file: json.dump(best_params, write_file, indent=4) def optuna_load_best_params(self, pair: str, namespace: str) -> Dict | None: best_params_path = Path( - self.full_path / f"{pair.split('/')[0]}_optuna_{namespace}_best_params.json" + self.full_path / f"optuna-{namespace}-best-params-{pair.split('/')[0]}.json" ) if best_params_path.is_file(): with best_params_path.open("r", encoding="utf-8") as read_file: