tensortrade.features.feature_pipeline module

class tensortrade.features.feature_pipeline.FeaturePipeline(steps, **kwargs)[source]

Bases: object

An pipeline for transforming observation data frames into features for learning.

__init__(steps, **kwargs)[source]
Parameters

dtype – The dtype elements in the pipeline should be cast to.

property dtype

The dtype that elements in the pipeline should be input and output as.

Return type

Union[type, str]

reset()[source]

Reset all transformers within the feature pipeline.

property steps

A list of feature transformations to apply to observations.

Return type

List[FeatureTransformer]

transform(observation, input_space)[source]

Apply the pipeline of feature transformations to an observation frame.

Parameters
  • observation (DataFrame) – A pandas.DataFrame corresponding to an observation within a TradingEnvironment.

  • input_space (Space) – A gym.Space matching the shape of the pipeline’s input.

Return type

DataFrame

Returns

A pandas.DataFrame of features corresponding to an input oversvation.

Raises

ValueError – In the case that an invalid observation frame has been input.

transform_space(input_space, column_names)[source]

Get the transformed output space for a given input space.

Parameters
  • input_space (Space) – A gym.Space matching the shape of the pipeline’s input.

  • column_names (List[str]) – A list of all column names in the input data frame.

Return type

Space

Returns

A gym.Space matching the shape of the pipeline’s output.