From a948796ef74449952a4f57268304f616e8a6aa33 Mon Sep 17 00:00:00 2001 From: robcaulk Date: Sun, 3 Mar 2024 15:47:19 +0100 Subject: [PATCH] fix: manually add train eval since xgboost does not expose this information by default --- .../freqai/prediction_models/XGBoostRegressor.py | 11 +++++++++-- freqtrade/freqai/tensorboard/tensorboard.py | 7 ++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/freqtrade/freqai/prediction_models/XGBoostRegressor.py b/freqtrade/freqai/prediction_models/XGBoostRegressor.py index f1a2474da..f3de6653b 100644 --- a/freqtrade/freqai/prediction_models/XGBoostRegressor.py +++ b/freqtrade/freqai/prediction_models/XGBoostRegressor.py @@ -36,8 +36,15 @@ class XGBoostRegressor(BaseRegressionModel): eval_set = None eval_weights = None else: - eval_set = [(data_dictionary["test_features"], data_dictionary["test_labels"])] - eval_weights = [data_dictionary['test_weights']] + eval_set = [ + (data_dictionary["test_features"], + data_dictionary["test_labels"]), + (X, y) + ] + eval_weights = [ + data_dictionary['test_weights'], + data_dictionary['train_weights'] + ] sample_weight = data_dictionary["train_weights"] diff --git a/freqtrade/freqai/tensorboard/tensorboard.py b/freqtrade/freqai/tensorboard/tensorboard.py index d91c70c81..3ad896108 100644 --- a/freqtrade/freqai/tensorboard/tensorboard.py +++ b/freqtrade/freqai/tensorboard/tensorboard.py @@ -43,10 +43,11 @@ class TensorBoardCallback(BaseTensorBoardCallback): if not evals_log: return False - for data, metric in evals_log.items(): - for metric_name, log in metric.items(): + evals = ["validation", "train"] + for metric, eval in zip(evals_log.items(), evals): + for metric_name, log in metric[1].items(): score = log[-1][0] if isinstance(log[-1], tuple) else log[-1] - self.writer.add_scalar(f"{data}-{metric_name}", score, epoch) + self.writer.add_scalar(f"{eval}-{metric_name}", score, epoch) return False