Feature Engineering vs. Feature Serving
What You'll Learn
You'll understand the critical difference between creating features for model training (offline) and computing them for real-time predictions (online).
The Core Distinction
Feature Engineering happens during model development and training. You work with historical data in batch, experimenting with transformations, aggregations, and derived values. You have time—minutes, hours, or even days—to compute complex features from large datasets. This is your laboratory environment.
Feature Serving happens at inference time in production. When a user makes a request, you need features immediately—often in milliseconds. You can't recompute month-long aggregations or scan massive datasets. You must retrieve or compute features fast enough to meet your latency SLA.
The Challenge: The Training-Serving Gap
The danger is feature skew: when training features differ from serving features. Imagine you engineered a "user's average purchase amount over 90 days" during training by scanning a data warehouse. In production, if you approximate this with a 7-day rolling average because the full calculation is too slow, your model sees different inputs than it was trained on—and performance degrades.
Common Solutions
- Precompute and cache: Store aggregated features in low-latency stores (Redis, feature stores)
- Feature stores: Tools like Feast or Tecton maintain consistency between offline (training) and online (serving) feature computation
- Simplified features: Design features that are fast to compute in real-time from the start
- Streaming pipelines: Use frameworks that update features continuously rather than on-demand
Key Takeaway: Feature engineering optimizes for model accuracy with time to spare; feature serving optimizes for latency and consistency. Bridging this gap without introducing skew is essential for production ML success.