diff --git a/docs/assets/tensorboard.jpg b/docs/assets/tensorboard.jpg new file mode 100644 index 000000000..2aefa869d Binary files /dev/null and b/docs/assets/tensorboard.jpg differ diff --git a/docs/freqai-running.md b/docs/freqai-running.md index b8994aed9..f6aa7b2e1 100644 --- a/docs/freqai-running.md +++ b/docs/freqai-running.md @@ -142,6 +142,20 @@ dataframe['outlier'] = np.where(dataframe['DI_values'] > self.di_max.value/10, 1 This specific hyperopt would help you understand the appropriate `DI_values` for your particular parameter space. +## Using Tensorboard + +Catboost models benefit from tracking training metrics via Tensorboard. You can take advantage of the FreqAI integration to track training and evaluation performance across all coins and across all retrainings. Tensorboard is activated via the following command: + +```bash +cd freqtrade +tensorboard --logdir user_data/models/unique-id +``` + +where `unique-id` is the `identifier` set in the `freqai` configuration file. This command must be run in a separate shell if the user wishes to view the output in their browser at 127.0.0.1:6060 (6060 is the default port used by Tensorboard). + +![tensorboard](assets/tensorboard.jpg) + + ## Setting up a follower You can indicate to the bot that it should not train models, but instead should look for models trained by a leader with a specific `identifier` by defining: diff --git a/freqtrade/freqai/data_kitchen.py b/freqtrade/freqai/data_kitchen.py index 0a4dd960c..a7e1d2808 100644 --- a/freqtrade/freqai/data_kitchen.py +++ b/freqtrade/freqai/data_kitchen.py @@ -119,6 +119,8 @@ class FreqaiDataKitchen: / f"sub-train-{pair.split('/')[0]}_{trained_timestamp}" ) + Path(self.data_path / 'tensorboard').mkdir(parents=True, exist_ok=True) + return def make_train_test_datasets( diff --git a/freqtrade/freqai/freqai_interface.py b/freqtrade/freqai/freqai_interface.py index 40fbd798c..ac980f5f1 100644 --- a/freqtrade/freqai/freqai_interface.py +++ b/freqtrade/freqai/freqai_interface.py @@ -196,7 +196,6 @@ class IFreqaiModel(ABC): (_, trained_timestamp, _) = self.dd.get_pair_dict_info(pair) dk = FreqaiDataKitchen(self.config, self.live, pair) - dk.set_paths(pair, trained_timestamp) ( retrain, new_trained_timerange, @@ -268,9 +267,7 @@ class IFreqaiModel(ABC): ) trained_timestamp_int = int(trained_timestamp.stopts) - dk.data_path = Path( - dk.full_path / f"sub-train-{pair.split('/')[0]}_{trained_timestamp_int}" - ) + dk.set_paths(pair, trained_timestamp_int) dk.set_new_model_names(pair, trained_timestamp) diff --git a/freqtrade/freqai/prediction_models/CatboostClassifier.py b/freqtrade/freqai/prediction_models/CatboostClassifier.py index 9a77644ed..6dab012d1 100644 --- a/freqtrade/freqai/prediction_models/CatboostClassifier.py +++ b/freqtrade/freqai/prediction_models/CatboostClassifier.py @@ -1,4 +1,5 @@ import logging +from pathlib import Path from typing import Any, Dict from catboost import CatBoostClassifier, Pool @@ -31,8 +32,9 @@ class CatboostClassifier(BaseClassifierModel): ) cbr = CatBoostClassifier( - allow_writing_files=False, + allow_writing_files=True, loss_function='MultiClass', + train_dir=Path(dk.data_path / 'tensorboard'), **self.model_training_parameters, ) diff --git a/freqtrade/freqai/prediction_models/CatboostRegressor.py b/freqtrade/freqai/prediction_models/CatboostRegressor.py index 73cf6c88a..46f33a142 100644 --- a/freqtrade/freqai/prediction_models/CatboostRegressor.py +++ b/freqtrade/freqai/prediction_models/CatboostRegressor.py @@ -1,4 +1,5 @@ import logging +from pathlib import Path from typing import Any, Dict from catboost import CatBoostRegressor, Pool @@ -41,7 +42,8 @@ class CatboostRegressor(BaseRegressionModel): init_model = self.get_init_model(dk.pair) model = CatBoostRegressor( - allow_writing_files=False, + allow_writing_files=True, + train_dir=Path(dk.data_path / 'tensorboard'), **self.model_training_parameters, ) diff --git a/freqtrade/freqai/prediction_models/CatboostRegressorMultiTarget.py b/freqtrade/freqai/prediction_models/CatboostRegressorMultiTarget.py index 7fa4e293e..085c13b86 100644 --- a/freqtrade/freqai/prediction_models/CatboostRegressorMultiTarget.py +++ b/freqtrade/freqai/prediction_models/CatboostRegressorMultiTarget.py @@ -1,4 +1,5 @@ import logging +from pathlib import Path from typing import Any, Dict from catboost import CatBoostRegressor, Pool @@ -26,7 +27,8 @@ class CatboostRegressorMultiTarget(BaseRegressionModel): """ cbr = CatBoostRegressor( - allow_writing_files=False, + allow_writing_files=True, + train_dir=Path(dk.data_path / 'tensorboard'), **self.model_training_parameters, ) diff --git a/requirements-freqai.txt b/requirements-freqai.txt index cf0d2eb07..c78b3b25e 100644 --- a/requirements-freqai.txt +++ b/requirements-freqai.txt @@ -7,3 +7,4 @@ joblib==1.2.0 catboost==1.1; platform_machine != 'aarch64' lightgbm==3.3.2 xgboost==1.6.2 +tensorboard==2.10.1