[Beta] On demand feature view
Warning: This is an experimental feature. While it is stable to our knowledge, there may still be rough edges in the experience. Contributions are welcome!
Overview
On Demand Feature Views (ODFVs) allow data scientists to use existing features and request-time data to transform and create new features. Users define transformation logic that is executed during both historical and online retrieval. Additionally, ODFVs provide flexibility in applying transformations either during data ingestion (at write time) or during feature retrieval (at read time), controlled via the write_to_online_store
parameter.
By setting write_to_online_store=True
, transformations are applied during data ingestion, and the transformed features are stored in the online store. This can improve online feature retrieval performance by reducing computation during reads. Conversely, if write_to_online_store=False
(the default if omitted), transformations are applied during feature retrieval.
Why Use On Demand Feature Views?
ODFVs enable data scientists to easily impact the online feature retrieval path. For example, a data scientist could:
Call
get_historical_features
to generate a training dataset.Iterate in a notebook and do your feature engineering using Pandas or native Python.
Copy transformation logic into ODFVs and commit to a development branch of the feature repository.
Verify with
get_historical_features
(on a small dataset) that the transformation gives the expected output over historical data.Decide whether to apply the transformation on writes or on reads by setting the
write_to_online_store
parameter accordingly.Verify with
get_online_features
on the development branch that the transformation correctly outputs online features.Submit a pull request to the staging or production branches, impacting production traffic.
Transformation Modes
When defining an ODFV, you can specify the transformation mode using the mode
parameter. Feast supports the following modes:
Pandas Mode (
mode="pandas"
): The transformation function takes a Pandas DataFrame as input and returns a Pandas DataFrame as output. This mode is useful for batch transformations over multiple rows.Native Python Mode (
mode="python"
): The transformation function uses native Python and can operate on inputs as lists of values or as single dictionaries representing a singleton (single row).
Singleton Transformations in Native Python Mode
Native Python mode supports transformations on singleton dictionaries by setting singleton=True
. This allows you to write transformation functions that operate on a single row at a time, making the code more intuitive and aligning with how data scientists typically think about data transformations.
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
When defining an ODFV, you can control when the transformation is applied using the write_to_online_store
parameter:
write_to_online_store=True
: The transformation is applied during data ingestion (on write), and the transformed features are stored in the online store.write_to_online_store=False
(default): The transformation is applied during feature retrieval (on read).
Examples
Example 1: On Demand Transformation on Read Using Pandas Mode
Example 2: On Demand Transformation on Read Using Native Python Mode (List Inputs)
New Example 3: On Demand Transformation on Read Using Native Python Mode (Singleton Input)
In this example, inputs
is a dictionary representing a single row, and the transformation function returns a dictionary of transformed features for that single row. This approach is more intuitive and aligns with how data scientists typically process single data records.
Example 4: On Demand Transformation on Write Using Pandas Mode
To ingest data with the new feature view, include all input features required for the transformations:
Feature Retrieval
Note: The name of the on demand feature view is the function name (e.g., transformed_conv_rate
).
Offline Features
Retrieve historical features by referencing individual features or using a feature service:
Online Features
Retrieve online features by referencing individual features or using a feature service:
CLI Commands
There are new CLI commands to manage on demand feature views:
feast on-demand-feature-views list: Lists all registered on demand feature views after feast apply is run. feast on-demand-feature-views describe [NAME]: Describes the definition of an on demand feature view.
Last updated