From a4b617e4824f633a03a65c4d6541f2e7587a7883 Mon Sep 17 00:00:00 2001 From: Yinon Polak Date: Mon, 20 Mar 2023 20:22:28 +0200 Subject: [PATCH] type hints fixes --- .../freqai/prediction_models/PyTorchMLPClassifier.py | 11 ++++------- .../freqai/prediction_models/PyTorchMLPRegressor.py | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/freqtrade/freqai/prediction_models/PyTorchMLPClassifier.py b/freqtrade/freqai/prediction_models/PyTorchMLPClassifier.py index edba75c2a..6b7d9c034 100644 --- a/freqtrade/freqai/prediction_models/PyTorchMLPClassifier.py +++ b/freqtrade/freqai/prediction_models/PyTorchMLPClassifier.py @@ -13,8 +13,7 @@ class PyTorchMLPClassifier(PyTorchClassifier): This class implements the fit method of IFreqaiModel. in the fit method we initialize the model and trainer objects. the only requirement from the model is to be aligned to PyTorchClassifier - predict method that expects the model to predict tensor of type long. - the trainer defines the training loop. + predict method that expects the model to predict a tensor of type long. parameters are passed via `model_training_parameters` under the freqai section in the config file. e.g: @@ -37,8 +36,6 @@ class PyTorchMLPClassifier(PyTorchClassifier): } } } - - """ def __init__( @@ -51,15 +48,15 @@ class PyTorchMLPClassifier(PyTorchClassifier): super().__init__(**kwargs) config = self.freqai_info.get("model_training_parameters", {}) self.learning_rate: float = config.get("learning_rate", learning_rate) - self.model_kwargs: Dict[str, any] = config.get("model_kwargs", model_kwargs) - self.trainer_kwargs: Dict[str, any] = config.get("trainer_kwargs", trainer_kwargs) + self.model_kwargs: Dict[str, Any] = config.get("model_kwargs", model_kwargs) + self.trainer_kwargs: Dict[str, Any] = config.get("trainer_kwargs", trainer_kwargs) def fit(self, data_dictionary: Dict, dk: FreqaiDataKitchen, **kwargs) -> Any: """ User sets up the training and test data to fit their desired model here :param data_dictionary: the dictionary constructed by DataHandler to hold all the training and test data/labels. - :raises ValueError: If self.class_names is not defined in the parent class. + :raises ValueError: If self.class_names is empty. """ class_names = self.get_class_names() diff --git a/freqtrade/freqai/prediction_models/PyTorchMLPRegressor.py b/freqtrade/freqai/prediction_models/PyTorchMLPRegressor.py index 06092c5a0..16e7c0e79 100644 --- a/freqtrade/freqai/prediction_models/PyTorchMLPRegressor.py +++ b/freqtrade/freqai/prediction_models/PyTorchMLPRegressor.py @@ -49,8 +49,8 @@ class PyTorchMLPRegressor(PyTorchRegressor): super().__init__(**kwargs) config = self.freqai_info.get("model_training_parameters", {}) self.learning_rate: float = config.get("learning_rate", learning_rate) - self.model_kwargs: Dict[str, any] = config.get("model_kwargs", model_kwargs) - self.trainer_kwargs: Dict[str, any] = config.get("trainer_kwargs", trainer_kwargs) + self.model_kwargs: Dict[str, Any] = config.get("model_kwargs", model_kwargs) + self.trainer_kwargs: Dict[str, Any] = config.get("trainer_kwargs", trainer_kwargs) def fit(self, data_dictionary: Dict, dk: FreqaiDataKitchen, **kwargs) -> Any: """