From eaae9c9e037890d38b5a6a8b1cc9883296285302 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 10 Oct 2022 12:15:30 +0000 Subject: [PATCH] Update docstring format --- .../freqai/base_models/BaseClassifierModel.py | 2 +- .../freqai/base_models/BaseRegressionModel.py | 2 +- freqtrade/freqai/data_drawer.py | 20 +++---- freqtrade/freqai/data_kitchen.py | 60 +++++++++---------- freqtrade/freqai/freqai_interface.py | 10 ++-- .../prediction_models/XGBoostClassifier.py | 2 +- 6 files changed, 44 insertions(+), 52 deletions(-) diff --git a/freqtrade/freqai/base_models/BaseClassifierModel.py b/freqtrade/freqai/base_models/BaseClassifierModel.py index 09f1bf98c..691c27e23 100644 --- a/freqtrade/freqai/base_models/BaseClassifierModel.py +++ b/freqtrade/freqai/base_models/BaseClassifierModel.py @@ -78,7 +78,7 @@ class BaseClassifierModel(IFreqaiModel): ) -> Tuple[DataFrame, npt.NDArray[np.int_]]: """ Filter the prediction features data and predict with it. - :param: unfiltered_df: Full dataframe for the current backtest period. + :param unfiltered_df: Full dataframe for the current backtest period. :return: :pred_df: dataframe containing the predictions :do_predict: np.array of 1s and 0s to indicate places where freqai needed to remove diff --git a/freqtrade/freqai/base_models/BaseRegressionModel.py b/freqtrade/freqai/base_models/BaseRegressionModel.py index 5d89dd356..79f6f0d3c 100644 --- a/freqtrade/freqai/base_models/BaseRegressionModel.py +++ b/freqtrade/freqai/base_models/BaseRegressionModel.py @@ -77,7 +77,7 @@ class BaseRegressionModel(IFreqaiModel): ) -> Tuple[DataFrame, npt.NDArray[np.int_]]: """ Filter the prediction features data and predict with it. - :param: unfiltered_df: Full dataframe for the current backtest period. + :param unfiltered_df: Full dataframe for the current backtest period. :return: :pred_df: dataframe containing the predictions :do_predict: np.array of 1s and 0s to indicate places where freqai needed to remove diff --git a/freqtrade/freqai/data_drawer.py b/freqtrade/freqai/data_drawer.py index 31c76a68e..465ba27f5 100644 --- a/freqtrade/freqai/data_drawer.py +++ b/freqtrade/freqai/data_drawer.py @@ -412,9 +412,8 @@ class FreqaiDataDrawer: def save_data(self, model: Any, coin: str, dk: FreqaiDataKitchen) -> None: """ Saves all data associated with a model for a single sub-train time range - :params: - :model: User trained model which can be reused for inferencing to generate - predictions + :param model: User trained model which can be reused for inferencing to generate + predictions """ if not dk.data_path.is_dir(): @@ -532,8 +531,7 @@ class FreqaiDataDrawer: Append new candles to our stores historic data (in memory) so that we do not need to load candle history from disk and we dont need to pinging exchange multiple times for the same candle. - :params: - dataframe: DataFrame = strategy provided dataframe + :param dataframe: DataFrame = strategy provided dataframe """ feat_params = self.freqai_info["feature_parameters"] with self.history_lock: @@ -579,9 +577,8 @@ class FreqaiDataDrawer: """ Load pair histories for all whitelist and corr_pairlist pairs. Only called once upon startup of bot. - :params: - timerange: TimeRange = full timerange required to populate all indicators - for training according to user defined train_period_days + :param timerange: TimeRange = full timerange required to populate all indicators + for training according to user defined train_period_days """ history_data = self.historic_data @@ -604,10 +601,9 @@ class FreqaiDataDrawer: """ Searches through our historic_data in memory and returns the dataframes relevant to the present pair. - :params: - timerange: TimeRange = full timerange required to populate all indicators - for training according to user defined train_period_days - metadata: dict = strategy furnished pair metadata + :param timerange: TimeRange = full timerange required to populate all indicators + for training according to user defined train_period_days + :param metadata: dict = strategy furnished pair metadata """ with self.history_lock: corr_dataframes: Dict[Any, Any] = {} diff --git a/freqtrade/freqai/data_kitchen.py b/freqtrade/freqai/data_kitchen.py index 7ea2daf02..0a4dd960c 100644 --- a/freqtrade/freqai/data_kitchen.py +++ b/freqtrade/freqai/data_kitchen.py @@ -107,9 +107,8 @@ class FreqaiDataKitchen: ) -> None: """ Set the paths to the data for the present coin/botloop - :params: - metadata: dict = strategy furnished pair metadata - trained_timestamp: int = timestamp of most recent training + :param metadata: dict = strategy furnished pair metadata + :param trained_timestamp: int = timestamp of most recent training """ self.full_path = Path( self.config["user_data_dir"] / "models" / str(self.freqai_config.get("identifier")) @@ -129,8 +128,8 @@ class FreqaiDataKitchen: Given the dataframe for the full history for training, split the data into training and test data according to user specified parameters in configuration file. - :filtered_dataframe: cleaned dataframe ready to be split. - :labels: cleaned labels ready to be split. + :param filtered_dataframe: cleaned dataframe ready to be split. + :param labels: cleaned labels ready to be split. """ feat_dict = self.freqai_config["feature_parameters"] @@ -189,13 +188,14 @@ class FreqaiDataKitchen: remove all NaNs. Any row with a NaN is removed from training dataset or replaced with 0s in the prediction dataset. However, prediction dataset do_predict will reflect any row that had a NaN and will shield user from that prediction. - :params: - :unfiltered_df: the full dataframe for the present training period - :training_feature_list: list, the training feature list constructed by - self.build_feature_list() according to user specified parameters in the configuration file. - :labels: the labels for the dataset - :training_filter: boolean which lets the function know if it is training data or - prediction data to be filtered. + + :param unfiltered_df: the full dataframe for the present training period + :param training_feature_list: list, the training feature list constructed by + self.build_feature_list() according to user specified + parameters in the configuration file. + :param labels: the labels for the dataset + :param training_filter: boolean which lets the function know if it is training data or + prediction data to be filtered. :returns: :filtered_df: dataframe cleaned of NaNs and only containing the user requested feature set. @@ -285,8 +285,8 @@ class FreqaiDataKitchen: def normalize_data(self, data_dictionary: Dict) -> Dict[Any, Any]: """ Normalize all data in the data_dictionary according to the training dataset - :params: - :data_dictionary: dictionary containing the cleaned and split training/test data/labels + :param data_dictionary: dictionary containing the cleaned and + split training/test data/labels :returns: :data_dictionary: updated dictionary with standardized values. """ @@ -516,8 +516,7 @@ class FreqaiDataKitchen: def pca_transform(self, filtered_dataframe: DataFrame) -> None: """ Use an existing pca transform to transform data into components - :params: - filtered_dataframe: DataFrame = the cleaned dataframe + :param filtered_dataframe: DataFrame = the cleaned dataframe """ pca_components = self.pca.transform(filtered_dataframe) self.data_dictionary["prediction_features"] = pd.DataFrame( @@ -561,8 +560,7 @@ class FreqaiDataKitchen: """ Build/inference a Support Vector Machine to detect outliers in training data and prediction - :params: - predict: bool = If true, inference an existing SVM model, else construct one + :param predict: bool = If true, inference an existing SVM model, else construct one """ if self.keras: @@ -647,11 +645,11 @@ class FreqaiDataKitchen: Use DBSCAN to cluster training data and remove "noisy" data (read outliers). User controls this via the config param `DBSCAN_outlier_pct` which indicates the pct of training data that they want to be considered outliers. - :params: - predict: bool = If False (training), iterate to find the best hyper parameters to match - user requested outlier percent target. If True (prediction), use the parameters - determined from the previous training to estimate if the current prediction point - is an outlier. + :param predict: bool = If False (training), iterate to find the best hyper parameters + to match user requested outlier percent target. + If True (prediction), use the parameters determined from + the previous training to estimate if the current prediction point + is an outlier. """ if predict: @@ -1118,15 +1116,13 @@ class FreqaiDataKitchen: prediction_dataframe: DataFrame = pd.DataFrame(), ) -> DataFrame: """ - Use the user defined strategy for populating indicators during - retrain - :params: - strategy: IStrategy = user defined strategy object - corr_dataframes: dict = dict containing the informative pair dataframes - (for user defined timeframes) - base_dataframes: dict = dict containing the current pair dataframes - (for user defined timeframes) - metadata: dict = strategy furnished pair metadata + Use the user defined strategy for populating indicators during retrain + :param strategy: IStrategy = user defined strategy object + :param corr_dataframes: dict = dict containing the informative pair dataframes + (for user defined timeframes) + :param base_dataframes: dict = dict containing the current pair dataframes + (for user defined timeframes) + :param metadata: dict = strategy furnished pair metadata :returns: dataframe: DataFrame = dataframe containing populated indicators """ diff --git a/freqtrade/freqai/freqai_interface.py b/freqtrade/freqai/freqai_interface.py index 394b98e94..40fbd798c 100644 --- a/freqtrade/freqai/freqai_interface.py +++ b/freqtrade/freqai/freqai_interface.py @@ -603,11 +603,11 @@ class IFreqaiModel(ABC): If the user reuses an identifier on a subsequent instance, this function will not be called. In that case, "real" predictions will be appended to the loaded set of historic predictions. - :param: df: DataFrame = the dataframe containing the training feature data - :param: model: Any = A model which was `fit` using a common library such as - catboost or lightgbm - :param: dk: FreqaiDataKitchen = object containing methods for data analysis - :param: pair: str = current pair + :param df: DataFrame = the dataframe containing the training feature data + :param model: Any = A model which was `fit` using a common library such as + catboost or lightgbm + :param dk: FreqaiDataKitchen = object containing methods for data analysis + :param pair: str = current pair """ self.dd.historic_predictions[pair] = pred_df diff --git a/freqtrade/freqai/prediction_models/XGBoostClassifier.py b/freqtrade/freqai/prediction_models/XGBoostClassifier.py index 3b14471c1..67c7c7783 100644 --- a/freqtrade/freqai/prediction_models/XGBoostClassifier.py +++ b/freqtrade/freqai/prediction_models/XGBoostClassifier.py @@ -64,7 +64,7 @@ class XGBoostClassifier(BaseClassifierModel): ) -> Tuple[DataFrame, npt.NDArray[np.int_]]: """ Filter the prediction features data and predict with it. - :param: unfiltered_df: Full dataframe for the current backtest period. + :param unfiltered_df: Full dataframe for the current backtest period. :return: :pred_df: dataframe containing the predictions :do_predict: np.array of 1s and 0s to indicate places where freqai needed to remove