12 — Pipeline & Automation

Feature Stores#

DataPractice 1 min read
◆ The PatternCentralized feature management with online/offline consistency

A feature store serves two stores from one source of truth: the offline store (historical data for training) and the online store (low-latency data for serving). This solves the training-serving skew problem — the features your model trains on are identical to what it sees in production.

// Interactive — feature store architecture
Pattern bridge: Feature stores solve training-serving skew just as survivorship bias prevention solves backtesting skew — both ensure the data you test on matches reality.
Worked example

Three training events, each joined to a 30-day order count. Joining the latest value gives 5, 5, 4; a point-in-time join, taking the value as it was at each event, gives 2, 5, 1. Two of three rows leaked the future. A model trained on the first version would look better in training than it can ever be live.

Where it misleads
  • A feature store does not prevent leakage by itself; the point-in-time join has to be used for every training set.
  • Online and offline values can still differ if they are computed by different code paths.
  • For a handful of models a feature store can be more infrastructure than the problem needs.
In code
events = pd.DataFrame({'user': [1, 1, 2], 'ts': pd.to_datetime(['2026-03-01', '2026-03-10', '2026-03-05'])})
feats = pd.DataFrame({'user': [1, 1, 2, 2], 'ts': pd.to_datetime(['2026-02-20', '2026-03-08', '2026-03-01', '2026-03-09']),
                      'orders_30d': [2, 5, 1, 4]})
latest = events.merge(feats.sort_values('ts').groupby('user').tail(1)[['user', 'orders_30d']], on='user')
as_of = pd.merge_asof(events.sort_values('ts'), feats.sort_values('ts'), on='ts', by='user')   # point-in-time
leaked = (latest.sort_values(['user', 'ts']).orders_30d.values != as_of.sort_values(['user', 'ts']).orders_30d.values).sum()
Python, in your browser — edit the code and run it again

Assumes import numpy as np and import pandas as pd. Each snippet carries its own example numbers; the comments say which are made up or simulated.

The same idea with a library
# Python — Feast feature store
from feast import FeatureStore

store = FeatureStore(repo_path=".")

# Online serving — low latency
features = store.get_online_features(
    features=["user_stats:avg_purchase",
              "user_stats:visit_count"],
    entity_rows=[{"user_id": 123}]
).to_dict()

# Offline training — point-in-time correct
training_df = store.get_historical_features(
    entity_df=entity_df,
    features=["user_stats:avg_purchase"]
).to_df()
Sources
  • S. Kaufman, S. Rosset, C. Perlich & O. Stitelman, “Leakage in Data Mining: Formulation, Detection, and Avoidance”, ACM Transactions on Knowledge Discovery from Data 6(4), 2012
  • Feast documentation, “Point-in-time joins”, feast.dev
  • Designing Machine Learning Systems, C. Huyen, O’Reilly, 2022

Last reviewed October 2026 · How this site checks its content · Report a mistake

Linked from 1
← Previous
ML Pipelines
Open in the full reader, with the topic sidebar