Feature Stores Cheat Sheet
Manage offline and online feature pipelines for ML with a feature store, covering feature views, materialization, and point-in-time joins.
Define a Feature View (Feast)
Declare a feature view over an offline source with an entity key and TTL.
from feast import Entity, FeatureView, Field, FileSourcefrom feast.types import Float32, Int64from datetime import timedeltadriver = Entity(name="driver_id", join_keys=["driver_id"])driver_stats_source = FileSource( path="data/driver_stats.parquet", timestamp_field="event_timestamp",)driver_stats_fv = FeatureView( name="driver_hourly_stats", entities=[driver], ttl=timedelta(days=1), schema=[Field(name="conv_rate", dtype=Float32), Field(name="trips", dtype=Int64)], source=driver_stats_source,)
Apply and Materialize
Register feature definitions and push offline features into the online store.
# register feature views/entities defined in feature_store.pyfeast apply# backfill the online store from the offline store up to nowfeast materialize-incremental $(date -u +%Y-%m-%dT%H:%M:%S)# inspect the registryfeast feature-views list
Point-in-Time Correct Training Data
Join historical features to labeled events without leaking future data.
from feast import FeatureStorestore = FeatureStore(repo_path=".")training_df = store.get_historical_features( entity_df=entity_df, # has driver_id + event_timestamp + label features=[ "driver_hourly_stats:conv_rate", "driver_hourly_stats:trips", ],).to_df()
Fetch Online Features at Inference
Retrieve the latest feature values for a set of entities with low-latency reads.
features = store.get_online_features( features=["driver_hourly_stats:conv_rate", "driver_hourly_stats:trips"], entity_rows=[{"driver_id": 1001}],).to_dict()print(features)
Core Concepts
Terminology used consistently across Feast, Tecton, and Databricks Feature Store.
- Entity- the primary key features are joined on (e.g. user_id, driver_id)
- Feature view- a group of related features tied to an entity and a source
- Offline store- historical feature values used to build training datasets
- Online store- low-latency key-value store serving features at inference time
- Materialization- the job that copies computed features from offline to online store
- Training-serving skew- mismatch between features seen at train time vs serve time; the problem feature stores solve
Always compute training data via get_historical_features with point-in-time joins rather than pulling straight from the online store — it's the only way to guarantee the model never trains on data that wasn't actually available at prediction time.
Explore Topics
Professional Web Designing Services
- Responsive Websites
- E-commerce Solutions
- SEO Friendly Design
- Fast & Secure
- Support & Maintenance