Skip to content

ObservationTable

An ObservationTable object is a representation of an observation set in the feature store. It combines historical points-in-time and entity values to make historical feature requests, usually for training and testing machine learning applications.

Creating ObservationTable Objects

To create an ObservationTable object, you can use either a SourceTable object or a View object.

Note

An accepted serving name must be used for the column containing the entity values.

The column containing points-in-time must be labelled "POINT_IN_TIME" and the point-in-time timestamps should be in UTC.

If you want to create an ObservationTable object from a SourceTable object,

  1. First select the relevant source table from the feature store.
    ds = fb.FeatureStore.get(<feature_store_name>).get_data_source()
    source_table = ds.get_source_table(
        database_name=<data_base_name>,
        schema_name=<schema_name>,
        table_name=<table_name>
    )
    
  2. Then use the create_observation_table method to create the ObservationTable object. Select the relevant columns and use the columns_rename_mapping parameter if the column names in the table are different from 'POINT-IN-TIME and an accepted serving name. Make sure to specify the desired sample size and the observation table name:
    observation_table = source_table.create_observation_table(
        name=<observation_table_name>,
        sample_rows=<desired_sample_size>,
        columns=[<timestamp_column_name>, <entity_column_name>],
        columns_rename_mapping={
            <timestamp_column_name>: "POINT_IN_TIME",
            <entity_column_name>: <entity_serving_name>,
        }
    )
    

If you want to create an ObservationTable object from an existing View object, use the create_observation_table method to create the ObservationTable object. Select the relevant columns and use the columns_rename_mapping parameter if the column names in the view are different from 'POINT-IN-TIME' and an accepted serving name. Again, make sure to specify the desired sample size and the observation table name:

observation_table = view.create_observation_table(
    name=<observation_table_name>,
    sample_rows=<desired_sample_size>,
    columns=[<timestamp_column_name>, <entity_column_name>],
    columns_rename_mapping={
        <timestamp_column_name>: "POINT_IN_TIME",
        <entity_column_name>: <entity_serving_name>,
    }
)

You can download the table by using the download() method:

observation_table.download()

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

observation_table.to_pandas()

If you no longer need an ObservationTable object and it is not used by any HistoricalFeatureTable object, you can delete it using the delete() method. This will delete the table in the feature store.

observation_table.delete()

Listing and Retrieving ObservationTable Objects

To list the ObservationTable objects in the catalog, use the list_observation_tables() method:

catalog.list_observation_tables()

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

observation_table = catalog.get_observation_table(<observation_table_name>)

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

observation_table = catalog.get_observation_table_by_id(<observation_table_id>)