Feature pipeline

On this page 7

A feature pipeline is the automated, repeatable process that transforms raw data into model-ready features and writes them to storage where training jobs and serving systems can read them. In MLOps & deployment, it is the first of the three pipelines in the common feature, training and inference architecture, and it owns everything between source systems and the feature values a model consumes.

The pipeline exists because feature logic written once in a notebook rarely survives production. Running the same versioned transformation code on a schedule or on a stream gives teams consistent features, traceable lineage and a single place to test data quality, which is the main defense against training-serving skew.

How a feature pipeline moves data to features

A feature pipeline reads source data, applies deterministic transformations, validates the output and materializes the result. Typical sources include transactional databases, event streams, data warehouses and third-party APIs. The output is usually written to a feature store with two layers: an offline store for large historical reads and an online store for low-latency lookups.

The stages below appear in almost every mature implementation, whatever the tooling. Each stage has a distinct responsibility and a distinct failure mode.

StageResponsibilityTypical failure if missing
IngestionRead new records from sourcesSilent gaps after source outages
TransformationAggregate, join, encode and window dataInconsistent logic across teams
ValidationCheck schema, ranges and null ratesCorrupted values reach the model
MaterializationWrite to offline and online storesStale features at inference time
RegistrationRecord feature definitions and versionsNo lineage for audits or rollback
Core stages of a feature pipeline

A crucial design rule is point-in-time correctness. When the pipeline builds training data, every feature value must reflect only what was known at the label timestamp. Joining a later value causes data leakage, which inflates offline metrics and collapses once the model faces live traffic.

Batch, streaming and on-demand feature computation

Feature pipelines differ mainly in when features are computed. The choice depends on how quickly a feature loses value and how much infrastructure a team can operate.

ModeFreshnessCommon enginesBest suited to
BatchHours to a daySpark, SQL warehouses, dbtCustomer profiles, monthly aggregates
StreamingSeconds to minutesFlink, Spark Structured Streaming, Kafka StreamsFraud signals, session activity counts
On-demandComputed per requestServing code or feature transformsFeatures that depend on the request itself
Computation modes and their trade-offs

Many production systems combine modes. A hybrid design computes slow-moving aggregates in batch, maintains rolling window counts in a stream and derives request-specific values, such as the distance between a user and a merchant, at inference time. The cost of this flexibility is that the same logic may exist in several engines, so teams define each feature once and generate engine-specific code where possible.

How it relates to training and inference pipelines

The feature pipeline is decoupled from model training on purpose. Separating the stages lets each run on its own cadence and scale independently, and it allows several models to share one curated set of features instead of duplicating preprocessing code.

PipelineInputOutputTypical cadence
Feature pipelineRaw source dataVersioned feature valuesContinuous or scheduled
Training pipelineFeatures and labelsModel artifact in a registryOn schedule or on drift
Inference pipelineFeatures and a modelPredictionsPer request or per batch
Feature, training and inference pipelines compared

This separation underpins continuous training: when drift detection triggers retraining, the training pipeline simply reads fresh features without rerunning expensive transformations. It also simplifies model lineage, because every model version can point to the exact feature versions it was trained on.

Designing and operating a reliable pipeline

Reliable feature pipelines share a small set of engineering practices. Transformations should be idempotent, so a rerun for the same time window produces identical output. Backfills must be supported, because new features need historical values before any model can learn from them.

  • Version feature definitions in source control and tie each version to its transformation code.
  • Validate every run with schema, range and freshness checks before writing to stores.
  • Monitor feature freshness and null rates as service-level indicators.
  • Document ownership so each feature has a named team responsible for its correctness.

The following decision table summarizes common situations and a reasonable starting design.

SituationRecommended approachReason
Daily scoring of a customer baseScheduled batch pipelineLowest cost, freshness is sufficient
Real-time fraud scoringStreaming plus online storeSignals decay within minutes
Several teams reuse featuresShared feature store with registryPrevents duplicated logic
Small team, one modelPipeline inside the training jobAvoids premature infrastructure
Choosing a feature pipeline design

Common failure modes and limitations

The most damaging failure is training-serving skew, which appears when the offline and online paths compute a feature differently. A typical cause is a batch job written in SQL and a separate serving implementation written in application code, with subtle differences in time zones, rounding or null handling.

Other recurring problems include silent upstream schema changes, late-arriving events that break window aggregates, and unbounded backfill costs when historical data is large. Feature pipelines also accumulate ML technical debt: unused features remain in production, consume compute and create hidden dependencies. Periodic feature pruning based on usage and importance keeps the pipeline maintainable.

A feature pipeline is not a complete answer to data quality. It can confirm that values are within expected ranges, but it cannot prove that a source system recorded reality correctly. Statistical checks such as the population stability index help detect gradual distribution shifts, yet they need thresholds tuned to each feature. Finally, a feature store adds operational overhead; for a single model with modest latency needs, a well-tested transformation module inside the training and serving code can be the more sensible choice.

In simple terms

A feature pipeline is like the prep kitchen in a restaurant. Raw ingredients arrive from suppliers. Cooks wash, cut and measure them. The prepared ingredients then wait in labeled containers for the chefs.

In machine learning, the raw ingredients are data. The prepared ingredients are features, such as a customer’s number of purchases last week. The pipeline does this work the same way every time. That consistency matters. A model gives reliable answers only when it sees data prepared exactly as it was during training.

A practical example

A mid-sized online retailer runs a model that flags risky card payments before checkout completes. The model needs features such as the number of orders from the same card in the last 10 minutes, the average basket value over 90 days and whether the shipping address is new.

The team builds a hybrid feature pipeline. A nightly batch job computes 90-day averages from the data warehouse. A streaming job reads checkout events and updates 10-minute counts in an online store within about two seconds. Validation rejects any run where null rates exceed 1 percent. Because both training data and live requests use the same feature definitions, offline accuracy matches production closely, and the team catches a broken upstream field within one hour instead of discovering it weeks later through falling fraud detection rates.