Skip to main content
LearnMLAcademy
Advanced10 min read

Production Data, Feature & ML Pipelines

Build scalable ML data and feature pipelines with automated schema validation, with pipeline maps, deployment choices, and production reliability checks.

What you will master in this lesson
Intuitive core mechanisms & practical real-world intuition
Step-by-step mathematical breakdown & visual diagrams
Runnable Python implementation & practical trade-offs

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

Core vocabulary
TermMeaning in this lesson
Batch ingestionMoves a bounded collection on a schedule, such as yesterday's billing records.
Streaming ingestionProcesses an ongoing sequence of timestamped events, usually with offsets or checkpoints.
Schema contractThe agreed field names, types, null rules, ranges, and compatibility expectations.
Feature freshnessHow old a feature value is relative to the decision that needs it.
BackfillA deliberate rerun for a past time interval after logic or source data is repaired.
Point-in-time correctnessUsing only information that was available at the historical prediction time.
Training-serving skewA difference between how a feature is calculated or supplied during training and live inference.

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?

Ingest day Dbatch or stream checkpoint
Validate contractschema, ranges, duplicates
Create featuresonly after validation passes
Train / batch scoredownstream dependency
Failure branchretry task; alert; backfill dates D−3…D after repair
How to read it: The graph exposes dependencies. A failed validation blocks feature creation and training; a retry resumes from the failed task, while a backfill reruns an earlier time range deliberately.

Pipeline operations are not interchangeable

Pipeline operations are not interchangeable
OperationUse whenDo not use when
RetryA transient request or worker failure is safe to repeatThe schema or transformation logic is wrong
BackfillPast partitions must be recomputed after a known repairYou cannot identify the affected time range
SkipAn optional branch has an explicit policyA required validation failed
Downstream runAll required upstream contracts passedAn input is incomplete merely because a timeout expired

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?

Versioned feature definitionorders_last_30_days(event_time, status='completed') · v4
↓
Offline feature storehistorical values by entity + event time → training and batch scoring
Online feature storelatest approved values by entity → low-latency live lookup

Same meaning and version; different storage and latency needs

How to read it: Offline storage keeps historical, point-in-time feature values for training and batch scoring. Online storage serves the latest approved values quickly. Both should come from versioned feature logic.

Offline and online feature serving

Offline and online feature serving
PropertyOfflineOnline
PurposeHistorical training, evaluation, and bulk scoringLow-latency features for one live entity
Typical accessLarge scans and point-in-time joinsKey lookup such as customer_id=C17
Time coverageMany historical versionsLatest approved value, sometimes short history
PriorityCorrect history and throughputFreshness, latency, and availability
Consistency controlSame versioned feature definitionSame versioned feature definition
Failure responseStop/backfill affected partitionsUse approved fallback, stale limit, or review path

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.

  1. Training definition: count all completed orders with event time in the preceding 30-day window. The historical result is 8.
  2. Serving implementation: count mobile events only. Five valid web orders are missing, so the live result is 3.
  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.
  4. 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.
  5. 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?

Training pipelinewarehouse: completed web + mobile orders
orders_last_30_days = 8customer C17 at cutoff time
Online pipelinemobile stream only; web source omitted
orders_last_30_days = 3same customer, incomplete calculation
Different input → different churn probability → inconsistent customer action
How to read it: Training counts eight completed orders in the prior 30 days; production counts only three mobile events. The model receives a different customer representation even though both systems call the field orders_last_30_days.

Point-in-time joins prevent the future from leaking backward

Which feature record was actually knowable when the prediction was made?

Day 0 · 10:00prediction cutoff
Day 0 · 16:00new transaction
Day 2chargeback label arrives
Correct training rowfeatures known by Day 0 10:00; later chargeback used only as outcome
Leaking rowuses Day 0 16:00 or Day 2 knowledge to predict at 10:00
How to read it: For a prediction at 10:00, the training row may use only facts available by 10:00. A chargeback reported two days later belongs to the label outcome, not the earlier feature set.

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.

Validate a small input contractPythonRUNNABLE PYTHON
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.

Express point-in-time feature logicCONCEPTUAL PSEUDOCODE
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

Observed failure → likely cause → controlled response
Observed failureLikely causeResponse
Live score differs from replayTraining-serving skewCompare raw inputs and feature versions for the same entity/time
Offline metric is implausibly highFuture leakage in join or splitRebuild rows using prediction-time cutoffs
Count increases after retryDuplicate events are not idempotentDeduplicate by stable event key before aggregation
Backfill corrupts new dataUnbounded or non-versioned rewriteWrite versioned output for an explicit range, validate, then promote

Connect to Earlier Lessons

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.

Apply this concept in a real hands-on project

You have studied the idea. Now use it in working Python code, see the calculation and output, and explain what changed. Each project includes step-by-step instructions, full source and tests.

Practice challenge: predict an outcome first, run the code, and explain the difference.

Track Your Progress0% curriculum done

Finished "Production Data, Feature & ML Pipelines"?

Mark this lesson as completed to update your progress bar and track your milestones across the full curriculum.

Overall Progress0 / 167 lessons

Was this tutorial helpful?

Your feedback helps us continuously refine and improve our open-access tutorials.

Knowledge Check

Progress: 0/5

Test your active recall. Choose one answer for each question, then check it to reveal the step-by-step reasoning.

Question 1 of 5debugging/diagnostic
Training computes orders_last_30_days as 8, but production computes 3 because web orders are omitted. What is the failure?
Question 2 of 5numerical/formula
Using score = 0.80 − 0.05 × orders_last_30_days, what live score results from the skewed value 3?
Question 3 of 5application/scenario
A training row predicts at Monday 10:00. Which fact is safe to use as an input feature?
Question 4 of 5practical selection
Validation fails because an upstream field changed type. What should orchestration do first?
Question 5 of 5conceptual
Why might one feature definition have both offline and online storage?

Knowledge Check Review & Explanations

Review the questions, verified correct answers, and conceptual explanations for this lesson.

1Training computes orders_last_30_days as 8, but production computes 3 because web orders are omitted. What is the failure?▼

Correct Answer: Training-serving skew

The feature has the same name but different source logic in training and serving, which is exactly training-serving skew.

2Using score = 0.80 − 0.05 × orders_last_30_days, what live score results from the skewed value 3?▼

Correct Answer: 0.65

0.05 × 3 = 0.15, then 0.80 − 0.15 = 0.65. The page contrasts it with 0.40 for the correct value 8.

3A training row predicts at Monday 10:00. Which fact is safe to use as an input feature?▼

Correct Answer: A transaction recorded Monday 09:30

Point-in-time correctness permits only information available by the 10:00 cutoff. Later facts may become labels or future features, not this row's inputs.

4Validation fails because an upstream field changed type. What should orchestration do first?▼

Correct Answer: Block dependent tasks and surface the contract failure

A structural defect needs diagnosis and an explicit compatibility decision. Downstream work must not consume an invalid contract.

5Why might one feature definition have both offline and online storage?▼

Correct Answer: Historical scans and low-latency current lookups have different access needs

Offline storage serves historical point-in-time workloads; online storage serves current values quickly. Shared meaning and versioning are still required.

Keep moving through the path

Continue Learning

Free Download: ML Interview Cheatsheet

100 essential Machine Learning interview questions and answers covering foundations, algorithms, evaluation, deep learning, Python, system design and interview strategy. Enter your email to download it instantly.

Next