Skip to content

HistoricalFeatureTable

A HistoricalFeatureTable object represents a table in the feature store containing historical feature values from a historical feature request. The historical feature values can also be obtained as a Pandas DataFrame, but using a HistoricalFeatureTable object has some benefits such as handling large tables, storing the data in the feature store for reuse, and offering full lineage of the training and test data.

Creating HistoricalFeatureTable Objects

A HistoricalFeatureTable object is created by getting historical features from a feature list by using the compute_historical_feature_table() method. The method uses as input an observation set that combines historical points-in-time and key values of the feature list's primary entity. Values of related serving entities can also be used.

The observation set should be an ObservationTable object. To create an ObservationTable object, please refer to the SDK reference of the ObservationTable object. You can also obtain an ObservationTable object from the catalog using the get_observation_table() method.

# Get the desired observation table
observation_table = catalog.get_observation_table(<observation_table_name>)
# Get the desired feature list
my_feature_list = catalog.get_feature_list(<feature_list_name>)
# Decide the name of the historical feature table
training_table_name = (
    '2y Features for Customer Purchase next 2w '
    'up to end 22 with Improved Feature List'
)
# Compute the historical feature table
training_table = my_feature_list.compute_historical_feature_table(
    observation_table,
    historical_feature_table_name=training_table_name
)

Note

compute_historical_feature_table only supports ObservationTable for now. Pandas DataFrame will be supported as input shortly.

You can also obtain historical features using the compute_historical_features() method which returns a loaded Pandas DataFrame instead of a HistoricalFeatureTable object and accepts a Pandas DataFrame as input.

You can download the HistoricalFeatureTable object using the download() method, or delete it using the delete() method. Deleting the object will delete the table in the feature store.

training_table.download()
training_table.delete()

You can convert the table to a Pandas DataFrame by using the to_pandas() method:

training_table.to_pandas()

Getting HistoricalFeatureTable Lineage

The HistoricalFeatureTable object contains metadata on the FeatureList and ObservationTable objects used, offering a full lineage of training or test data. To access their Object IDs, use the feature_list_id and observation_table_id properties.

training_table.feature_list_id
training_table.observation_table_id

Listing and Retrieving HistoricalFeatureTable Objects

To list the HistoricalFeatureTable objects in the catalog, use the list_historical_feature_tables() method:

catalog.list_historical_feature_tables()

To retrieve a specific HistoricalFeatureTable by its name from the catalog, use the get_historical_feature_table() method:

training_table = catalog.get_historical_feature_table(
    <historical_feature_table_name>
)

To retrieve a specific HistoricalFeatureTable by its Object ID from the catalog, use the get_historical_feature_table_by_id() method:

training_table = catalog.get_historical_feature_table_by_id(
    <historical_feature_table_id>
)