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
On-Demand Transformations (Feast ODFV)
Compute request-time features that combine stored features with values only available at inference time.
from feast import RequestSource, Fieldfrom feast.types import Float32from feast import on_demand_feature_viewimport pandas as pdinput_request = RequestSource( name="trip_request", schema=[Field(name="trip_distance_km", dtype=Float32)],)@on_demand_feature_view( sources=[driver_stats_fv, input_request], schema=[Field(name="eta_adjusted", dtype=Float32)],)def eta_features(inputs: pd.DataFrame) -> pd.DataFrame: out = pd.DataFrame() out["eta_adjusted"] = inputs["trip_distance_km"] / inputs["conv_rate"].clip(lower=0.1) return out
Streaming Feature Ingestion via Push Source
Write freshly computed features directly into the online (and optionally offline) store from a streaming job.
from feast import FeatureStorefrom feast.data_source import PushModeimport pandas as pdstore = FeatureStore(repo_path=".")event_df = pd.DataFrame({ "driver_id": [1001], "conv_rate": [0.83], "trips": [42], "event_timestamp": [pd.Timestamp.now()],})# ONLINE writes to the online store only; ONLINE_AND_OFFLINE also appends# to the offline store for future point-in-time training queriesstore.push("driver_stats_push_source", event_df, to=PushMode.ONLINE_AND_OFFLINE)
Query Features Over HTTP (Feature Server)
Fetch online features from a language-agnostic serving process instead of embedding the Python SDK in your inference service.
# start the feature server (wraps get_online_features as a REST API)feast serve --host 0.0.0.0 --port 6566# fetch features from any client, e.g. curlcurl -X POST http://localhost:6566/get-online-features \ -H "Content-Type: application/json" \ -d '{ "features": ["driver_hourly_stats:conv_rate", "driver_hourly_stats:trips"], "entities": {"driver_id": [1001]} }'
Group Features into a Feature Service
Bundle the exact feature set a model version depends on so training and serving always request an identical, versioned contract.
from feast import FeatureServicefraud_v2_features = FeatureService( name="fraud_model_v2", features=[ driver_stats_fv[["conv_rate", "trips"]], eta_features, ],)# at serving time, request by service name — no need to enumerate# individual feature references, and it's tied to a model version in the registryfeatures = store.get_online_features( features=store.get_feature_service("fraud_model_v2"), entity_rows=[{"driver_id": 1001}],).to_dict()
Common Feature Store Pitfalls
Failure modes that are easy to introduce even with a feature store in place.
- Label leakage via wrong join- using an entity_df timestamp after the label was observed instead of the decision time
- Online/offline schema drift- a feature view's schema changes without re-materializing, causing silent type mismatches
- Stale online store- materialize-incremental jobs failing silently while inference keeps serving old values
- Entity key cardinality skew- a small number of hot entity keys overload the online store's read path
- Untracked ad-hoc features- features computed inline in the model code instead of registered, so they can't be reused or audited
- TTL mismatch- a feature view's ttl shorter than the model's real staleness tolerance, silently nulling features
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.