tensortrade.pipeline.transformers.catboost_feature_importance module

class tensortrade.pipeline.transformers.catboost_feature_importance.CatBoostFeatureImportanceTransformer(num_features: int = 20, seed: int = 42, *, iterations: int = 1000, target_column: str = 'close', target_shift: int = 3, task_type: str = 'CPU', learning_rate: float | None = None, max_depth: int = 8)[source]

Bases: AbstractTransformer

Transformer for selecting top features based on feature importance with a target variable, calculated by CatBoostRegressor.

Parameters:
  • num_features (int) – The number of top features to select. (Default = 20)

  • seed (int) – The seed used for the feature importance score regression. (Default = 42)

  • iterations (int) – CatBoostRegressor iterations. Should be at minimum 5 to 10 times the number of features. (Default = 1000)

  • target_column (str) – The name of the target column on which the mutual information score should be calculated. (Default = ‘close’)

  • target_shift (int) – The number of periods to shift the target column to create the prediction target. (Default = 3)

  • task_type (str) – The type of the CatBoostRegressor task, can be CPU or GPU. (Default = ‘CPU’)

  • learning_rate (float) – Learning rate used for the CatBoostRegressor. If None it is chosen dynamical by CatBoost.

  • max_depth (int) – Max depth used for the CatBoostRegressor. (Default = 8)

transform(df: DataFrame) DataFrame[source]

Transforms the input DataFrame by selecting the top features based on feature importance score with the target variable, calculated with CatBoostRegressor

Parameters:

df (DataFrame) – The input DataFrame containing the features and target column.

Returns:

A DataFrame reduced to the top features based on feature importance scores.

Return type:

DataFrame