Sub topic 1
Why Feature Stores Exist: Reuse and Training-Serving Skew
Prerequisites
This chapter assumes Python basics, including pandas DataFrames, and a basic machine learning workflow. You should know that a model learns from features and labels during training, then uses features to make predictions during inference. You should also understand the difference between batch processing and low-latency online requests.
A feature is an input value used by a machine learning model. For a driver-risk model, examples might include a driver's acceptance rate, average daily trips, and number of late deliveries.
The Feature Management Problem
Teams often calculate the same feature in several places:
- A batch job calculates features for training.
- A notebook calculates them again for experiments.
- An application calculates them again when serving predictions.
- A monitoring job may calculate them a fourth time.
This duplication creates two problems. First, engineers spend time maintaining repeated logic. Second, the values used during training may differ from the values used during inference.
A feature store is a system that defines, stores, and serves features for both training and inference. It gives a team one managed definition of a feature and provides different access paths for historical and current data.
For example, suppose a model uses conv_rate, the percentage of customer requests accepted by a driver. During training, the model needs the value that was known at each historical training time. During inference, the application needs the driver's latest available value within a small latency budget.
Training-Serving Skew
Training-serving skew is a difference between the features used to train a model and the features supplied to that model in production.
Consider this process:
- A training script calculates a driver's acceptance rate over the previous 24 hours.
- A production service calculates acceptance rate over all of the driver's history.
- The model receives values with different meanings during training and serving.
The model may perform well in testing but poorly in production because it learned from one definition and predicts with another.
A feature store reduces this risk by centralizing the feature definition and making the same feature available through historical and online retrieval APIs. It does not automatically guarantee correctness. The source data, timestamps, transformations, and deployment process must still be designed carefully.
Reuse Through a Feature Store
A feature store lets multiple models use a feature such as avg_daily_trips without each team rebuilding it. A central definition also makes ownership, data types, freshness expectations, and documentation easier to inspect.
The two access patterns have different goals:
| Access pattern | Main use | Typical data |
|---|---|---|
| Historical retrieval | Building training and evaluation data | Many entities and past timestamps |
| Online retrieval | Serving one prediction request | A few entities and their latest values |
The same logical feature can therefore have two physical representations. Historical values remain in an offline store suited to large scans. Recent values are copied into an online store suited to fast key-based reads.
A Practical Boundary
Use a feature store when features are reused, when several models need consistent definitions, or when training and serving use different storage systems. A feature store may add unnecessary operational work for a small experiment with one model and a single data pipeline.
The key question is not whether every input belongs in a feature store. Ask whether the feature has a stable definition, a clear owner, and a reason to be shared between historical training and production inference.
Exercise
A model is trained with a driver's acceptance rate from the previous 24 hours, but production supplies the driver's lifetime acceptance rate. What problem does this create, and how can a feature store help?
Show answer
It creates training-serving skew because the feature has different meanings in training and production. A feature store can centralize the definition and expose consistent historical and online retrieval paths, although the pipelines still need correct timestamps and freshness rules.