Skip to content

featurebyte.FeatureList.preview

preview(
observation_set: Union[ObservationTable, DataFrame],
serving_names_mapping: Optional[Dict[str, str]]=None
) -> Optional[DataFrame]

Description

Materializes a FeatureList using a small observation set of up to 50 rows. Unlike compute_historical_features, this method does not store partial aggregations (tiles) to speed up future computation. Instead, it computes the features on the fly, and should be used only for small observation sets for debugging or prototyping unsaved features.

The small observation set should combine historical points-in-time and key values of the primary entity from the feature list. Associated serving entities can also be utilized.

Parameters

  • observation_set: Union[ObservationTable, DataFrame]
    Observation set with POINT_IN_TIME and serving names columns. This can be either an ObservationTable or a pandas DataFrame.

  • serving_names_mapping: Optional[Dict[str, str]]
    Optional serving names mapping if the observation table has different serving name

Returns

  • Optional[DataFrame]
    Materialized feature values. The returned DataFrame will have the same number of rows, and include all columns from the observation set.

Note: POINT_IN_TIME values will be converted to UTC time.

Examples

Create a feature list with two features.

>>> features = fb.FeatureList([
...    catalog.get_feature("InvoiceCount_60days"),
...    catalog.get_feature("InvoiceAmountAvg_60days"),
... ], name="My new feature list")

Prepare observation set with POINT_IN_TIME and serving names columns.

>>> observation_set = pd.DataFrame({
...    "POINT_IN_TIME": ["2022-06-01 00:00:00", "2022-06-02 00:00:00"],
...    "GROCERYCUSTOMERGUID": [
...      "a2828c3b-036c-4e2e-9bd6-30c9ee9a20e3",
...      "ac479f28-e0ff-41a4-8e60-8678e670e80b",
...    ],
... })

Preview the feature list with a small observation set.

>>> features.preview(observation_set)
    POINT_IN_TIME  GROCERYCUSTOMERGUID                   InvoiceCount_60days  InvoiceAmountAvg_60days
0   2022-06-01     a2828c3b-036c-4e2e-9bd6-30c9ee9a20e3  10.0                 7.938
1   2022-06-02     ac479f28-e0ff-41a4-8e60-8678e670e80b  6.0                  9.870