Skip to content

featurebyte.View.as_features

as_features(
column_names: List[str],
feature_names: List[str],
offset: Union[str, NoneType]=None
) -> FeatureGroup

Description

Creates lookup features directly from the column in the View. The primary entity associated with the features is identified by the primary key of the table. However, if the View is a Slowly Changing Dimension (SCD) view, the primary entity is identified by the natural key of the table.

For SCD views, lookup features are materialized through point-in-time joins, and the resulting value represents the active row at the point-in-time indicated in the feature request. For instance, a customer feature could be the customer's street address at the point-in-time indicated in the request. To obtain a feature value at a specific time prior to the request's point-in-time, an offset can be specified. For example, setting the offset to 9 weeks would represent the customer's street address 9 weeks prior to the request's point-in-time.

The returned object is a FeatureGroup which is a temporary collection of Feature objects.

It is possible to perform additional transformations on the Feature objects, and the Feature objects are added to the catalog solely when explicitly saved.

Parameters

  • column_names: List[str]
    Column names to be used to create the features

  • feature_names: List[str]
    Feature names corresponding to column_names

  • offset: Union[str, NoneType]
    When specified, retrieve feature values as of this offset prior to the point-in-time

Returns

  • FeatureGroup

Raises

  • ValueError
    When any of the specified parameters are invalid

Examples

>>> features = dimension_view.as_features(
...    column_names=["column_a", "column_b"],
...    feature_names=["Feature A", "Feature B"],
... )
>>> features.feature_names
['Feature A', 'Feature B']