Make training and serving use the same feature meaning
A model cannot correct a missing column, a duplicated payment event, or a feature that means one thing during training and another during prediction. Production data pipelines make inputs dependable; feature pipelines turn those inputs into consistent model-ready values.
A pipeline is a dependency graph—a directed acyclic graph, or DAG—whose tasks run only when their required upstream outputs are ready. It also records time ranges, versions, attempts, and outcomes so failed work can be retried or historical periods can be backfilled safely.
What You Will Be Able to Explain
- Trace batch and streaming ingestion through validation and transformations
- Explain schema contracts, evolution, retries, and backfills
- Distinguish offline and online feature storage
- Diagnose training-serving skew with actual values
- Build point-in-time training rows without future leakage
Features, event time and pipeline contracts
These terms name different responsibilities. Read the meaning before following them through the diagrams and worked example.
Core vocabulary
Reliable features require meaning, time, and lineage
Ingestion identifies a source, event time, arrival time, and unique event key. Validation then checks schema, allowed categories, numeric ranges, missingness, timestamp sanity, and duplicates. A compatible optional column may be accepted; silently changing age from an integer in years to a string in months is not compatible evolution.
Transformations clean and aggregate approved records. Each feature definition needs an owner, entity key, event-time rule, source lineage, version, freshness expectation, and safe missing-value behaviour. The field name alone is not a contract.
Orchestration records dependencies. If validation fails, downstream feature and training tasks stay blocked. A transient task may retry with bounded backoff; a broken contract needs repair, not endless retry. A backfill explicitly recomputes dates or partitions affected by corrected logic.
A pipeline is a dependency graph, not merely a list
Why may downstream work run only after its required inputs succeed?
Pipeline operations are not interchangeable
Serve historical features and live features for different needs
An offline feature store retains historical values for training and batch scoring. An online store prioritizes fast access to the latest approved values for a live entity. A feature-store product is optional; the important concept is consistent, reusable feature definitions with different retrieval needs.
One feature definition, two serving needs
How can training and live prediction use the same feature meaning?
Offline and online feature serving
Worked Example: Calculate skew and prevent future leakage
Given: Feature orders_last_30_days is defined for customer C17 at 1 June 10:00. Training reads completed web and mobile orders and counts 8. The online job accidentally reads only the mobile stream and counts 3.
- Training definition: count all completed orders with event time in the preceding 30-day window. The historical result is 8.
- Serving implementation: count mobile events only. Five valid web orders are missing, so the live result is 3.
- If a toy churn model uses score = 0.80 − 0.05 × orders_last_30_days, training-like input gives 0.80 − 0.05 × 8 = 0.40.
- The skewed live input gives 0.80 − 0.05 × 3 = 0.65. With a decision threshold of 0.60, the same customer changes from no alert to alert.
- For the historical row at 1 June 10:00, join only features known by that cutoff. A chargeback reported on 3 June may supply the later outcome label but must not enter the earlier features.
Result and interpretation: The 0.25 score difference came from inconsistent data logic, not a changing model. Shared versioned feature code and parity tests reduce skew; event-time-aware joins prevent unrealistically good training results caused by future information.
The following figures turn the example into an operational decision. Follow every branch and note which state is recorded before work continues.
Training-serving skew changes the model input
What happens when the same feature name is calculated differently?
Point-in-time joins prevent the future from leaking backward
Which feature record was actually knowable when the prediction was made?
Express feature contracts and time cutoffs in code
The label above each block states what it is. Runnable Python can be executed as shown with the standard library; pseudocode and configuration communicate architecture and require adaptation to a real platform.
Validate a small input contract
This transparent example rejects missing fields, impossible values, and duplicate event IDs before feature logic runs.
REQUIRED = {"event_id", "customer_id", "event_time", "amount"}
def validate_event(event, seen_ids):
missing = REQUIRED - event.keys()
assert not missing, f"missing fields: {sorted(missing)}"
assert event["amount"] >= 0, "amount must be non-negative"
assert event["event_id"] not in seen_ids, "duplicate event"
seen_ids.add(event["event_id"])
return event
seen = set()
validate_event({"event_id":"e1", "customer_id":"C17",
"event_time":"2026-06-01T09:40:00Z", "amount":24.0}, seen)Express point-in-time feature logic
The cutoff belongs to each training example. The join filters by event time before aggregating.
for training_row in prediction_times:
eligible = orders.where(
order.customer_id == training_row.customer_id
and training_row.cutoff - 30_days <= order.event_time
and order.event_time <= training_row.cutoff
and order.status == "completed"
)
training_row.orders_last_30_days = count(eligible)Choose freshness, recovery and feature ownership policies
- Use batch ingestion when bounded delay is acceptable; use streaming only when event freshness changes the decision enough to justify state and recovery complexity.
- Define compatibility rules for schema evolution rather than accepting or rejecting every change uniformly.
- Keep event time separate from arrival time so late events and point-in-time joins can be handled explicitly.
- Set feature freshness and missing-value policies from the decision risk; do not allow accidental framework defaults.
Failure Analysis and Recovery
Observed failure → likely cause → controlled response
Connect to Earlier Lessons
- Feature engineering
Review how raw variables become useful model inputs.
- Handling missing data
Choose explicit missing-data strategies before production defaults.
- Batch versus online learning
Separate model update cadence from prediction serving mode.
Summary / Key Takeaways
- A production pipeline is a versioned dependency graph with contracts, run state, retries, and deliberate backfills.
- Batch and streaming ingestion differ in freshness, state, failure recovery, and complexity.
- Feature definitions require entity keys, time rules, sources, versions, freshness, and missing-value behaviour—not only names.
- Offline features preserve point-in-time history; online features serve approved current values with low latency.
- Training-serving skew occurs when the same feature meaning is implemented differently and can change the final decision.
- Point-in-time correctness prevents future facts from leaking into historical training inputs.
- Validation blocks bad inputs before downstream work; it does not prove that a statistically valid feature remains useful.