[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.
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 afterfeast apply
is runfeast 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
:
# Define a request data source which encodes features / information only
# available at request time (e.g. part of the user initiated HTTP request)
input_request = RequestDataSource(
name="vals_to_add",
schema={
"val_to_add": ValueType.INT64,
"val_to_add_2": ValueType.INT64
}
)
# Use the input data and feature view features to create new features
@on_demand_feature_view(
inputs={
'driver_hourly_stats': driver_hourly_stats_view,
'vals_to_add': input_request
},
features=[
Feature(name='conv_rate_plus_val1', dtype=ValueType.DOUBLE),
Feature(name='conv_rate_plus_val2', dtype=ValueType.DOUBLE)
]
)
def transformed_conv_rate(features_df: pd.DataFrame) -> pd.DataFrame:
df = pd.DataFrame()
df['conv_rate_plus_val1'] = (features_df['conv_rate'] + features_df['val_to_add'])
df['conv_rate_plus_val2'] = (features_df['conv_rate'] + features_df['val_to_add_2'])
return df
Feature retrieval
And then to retrieve historical or online features, we can call this in a feature service or reference individual features:
training_df = store.get_historical_features(
entity_df=entity_df,
features=[
"driver_hourly_stats:conv_rate",
"driver_hourly_stats:acc_rate",
"driver_hourly_stats:avg_daily_trips",
"transformed_conv_rate:conv_rate_plus_val1",
"transformed_conv_rate:conv_rate_plus_val2",
],
).to_df()
Last updated
Was this helpful?