tensortrade.pipeline.transformers.univariate_feature_selection module¶
- class tensortrade.pipeline.transformers.univariate_feature_selection.UnivariateFeatureSelectionTransformer(num_features: int = 20, *, target_column: str = 'close', target_shift: int = 3, problem_type: str = 'regression')[source]¶
Bases:
AbstractTransformer
Transformer that does univariate feature selection.
It removes the features to num_features either by regression or classification.
- 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)
problem_type (str) – The problem type to solve, either classification or regression. (Default = ‘regression’)
- transform(df: DataFrame) DataFrame [source]¶
Reduces features by univariate feature selection.
- Parameters:
df (DataFrame) – The input DataFrame containing the features and target column.
- Returns:
A DataFrame reduced to the top features based on univariate feature selection.
- Return type:
DataFrame
- Raises:
ValueError – If the problem_type is not ‘regression’ or ‘classification’.