Search…
Feature view

Feature views

A feature view is an object that represents a logical group of time-series feature data as it is found in a data source. Feature views consist of zero or more entities, one or more features, and a data source. Feature views allow Feast to model your existing feature data in a consistent way in both an offline (training) and online (serving) environment. Feature views generally contain features that are properties of a specific object, in which case that object is defined as an entity and included in the feature view. If the features are not related to a specific object, the feature view might not have entities; see feature views without entities below.
driver_trips_feature_view.py
1
driver_stats_fv = FeatureView(
2
name="driver_activity",
3
entities=["driver"],
4
features=[
5
Feature(name="trips_today", dtype=ValueType.INT64),
6
Feature(name="rating", dtype=ValueType.FLOAT),
7
],
8
batch_source=BigQuerySource(
9
table_ref="feast-oss.demo_data.driver_activity"
10
)
11
)
Copied!
Feature views are used during
    The generation of training datasets by querying the data source of feature views in order to find historical feature values. A single training dataset may consist of features from multiple feature views.
    Loading of feature values into an online store. Feature views determine the storage schema in the online store.
    Retrieval of features from the online store. Feature views provide the schema definition to Feast in order to look up features from the online store.
Feast does not generate feature values. It acts as the ingestion and serving system. The data sources described within feature views should reference feature values in their already computed form.

Feature views without entities

If a feature view contains features that are not related to a specific entity, the feature view can be defined without entities.
global_stats.py
1
global_stats_fv = FeatureView(
2
name="global_stats",
3
entities=[],
4
features=[
5
Feature(name="total_trips_today_by_all_drivers", dtype=ValueType.INT64),
6
],
7
batch_source=BigQuerySource(
8
table_ref="feast-oss.demo_data.global_stats"
9
)
10
)
Copied!

Feature

A feature is an individual measurable property. It is typically a property observed on a specific entity, but does not have to be associated with an entity. For example, a feature of a customer entity could be the number of transactions they have made on an average month, while a feature that is not observed on a specific entity could be the total number of posts made by all users in the last month.
Features are defined as part of feature views. Since Feast does not transform data, a feature is essentially a schema that only contains a name and a type:
1
trips_today = Feature(
2
name="trips_today",
3
dtype=ValueType.FLOAT
4
)
Copied!
Together with data sources, they indicate to Feast where to find your feature values, e.g., in a specific parquet file or BigQuery table. Feature definitions are also used when reading features from the feature store, using feature references.
Feature names must be unique within a feature view.

[Alpha] On demand feature views

On demand feature views allows users to use existing features and request time data (features only available at request time) to transform and create new features. Users define python transformation logic which is executed in both historical retrieval and online retrieval paths:
1
# Define a request data source which encodes features / information only
2
# available at request time (e.g. part of the user initiated HTTP request)
3
input_request = RequestDataSource(
4
name="vals_to_add",
5
schema={
6
"val_to_add": ValueType.INT64,
7
"val_to_add_2": ValueType.INT64
8
}
9
)
10
11
# Use the input data and feature view features to create new features
12
@on_demand_feature_view(
13
inputs={
14
'driver_hourly_stats': driver_hourly_stats_view,
15
'vals_to_add': input_request
16
},
17
features=[
18
Feature(name='conv_rate_plus_val1', dtype=ValueType.DOUBLE),
19
Feature(name='conv_rate_plus_val2', dtype=ValueType.DOUBLE)
20
]
21
)
22
def transformed_conv_rate(features_df: pd.DataFrame) -> pd.DataFrame:
23
df = pd.DataFrame()
24
df['conv_rate_plus_val1'] = (features_df['conv_rate'] + features_df['val_to_add'])
25
df['conv_rate_plus_val2'] = (features_df['conv_rate'] + features_df['val_to_add_2'])
26
return df
Copied!
Last modified 11d ago