Search…
[Alpha] On demand feature view
Warning: This is an experimental feature. It's intended for early testing and feedback, and could change without warnings in future releases.
To enable this feature, run feast alpha enable enable_on_demand_transforms

Overview

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.
Currently, these transformations are executed locally. Future milestones include building a Feature Transformation Server for executing transformations at higher scale.

CLI

There are new CLI commands:
    feast on-demand-feature-views list lists all registered on demand feature view after feast apply is run
    feast on-demand-feature-views describe [NAME] describes the definition of an on demand feature view

Example

See https://github.com/feast-dev/on-demand-feature-views-demo for an example on how to use on demand feature views.

Registering transformations

We register RequestDataSource inputs and the transform in on_demand_feature_view:
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!

Feature retrieval

The on demand feature view's name is the function name (i.e. transformed_conv_rate).
And then to retrieve historical or online features, we can call this in a feature service or reference individual features:
1
training_df = store.get_historical_features(
2
entity_df=entity_df,
3
features=[
4
"driver_hourly_stats:conv_rate",
5
"driver_hourly_stats:acc_rate",
6
"driver_hourly_stats:avg_daily_trips",
7
"transformed_conv_rate:conv_rate_plus_val1",
8
"transformed_conv_rate:conv_rate_plus_val2",
9
],
10
).to_df()
Copied!
Last modified 28d ago