tensortrade.pipeline.transformers.lasso_feature_selection module

class tensortrade.pipeline.transformers.lasso_feature_selection.LassoFeatureSelectionTransformer(num_features: int = 20, *, target_column: str = 'close', target_shift: int = 3, alpha: float = 0.01, max_iterations: int = 1000, seed: int = 42)[source]

Bases: AbstractTransformer

Transformer that uses Lasso L1 regularization to select the most important features.

Params num_features:

The number of features that should be returned. (Default = 20)

Parameters:
  • 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)

  • alpha (float) – The alpha (strength of regularization) of lasso. (Default = 0.01)

  • max_iterations (int) – The max_iterations of lasso. (Default = 1000)

  • seed (int) – The seed used for lasso. (Default = 42)

transform(df: DataFrame) DataFrame[source]

Reduces features by lasso l1 regularization.

Parameters:

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

Returns:

A DataFrame reduced to the top features based on lasso l1 regularization.

Return type:

DataFrame