← All projects

Case study 04 / ML Engineering · Software Engineering

ML features without future leakage.

A Go feature store with historical training joins, Parquet offline storage, and Redis online serving.

  • Go
  • Redis
  • Parquet
  • PySpark

The problem

A model can look excellent offline if its training features contain information that only became available after a prediction event. How can a feature store prevent that leakage?

What I built

Built a YAML feature registry, event-time materialization of hourly driver snapshots into Parquet, online serving of each driver’s latest snapshot from Redis, and an HTTP API for online and historical retrieval. A separate PySpark job demonstrates batch aggregation on larger inputs.

How it works

The registry describes entities, feature views, and TTLs. Materialization turns completed trips into hourly snapshots, keeps the history in Parquet, and publishes each driver’s latest closed snapshot to Redis. Historical retrieval picks, for each event, the newest snapshot at or before the event and within the TTL.

  1. Feature registry
  2. Materialization
  3. Parquet / Redis
  4. Training / inference
A simplified flow; implementation details are linked below.

Engineering decisions

Time is part of correctness

Historical joins reject snapshots after the event and snapshots older than the 24-hour TTL. An event with no eligible snapshot keeps missing features rather than borrowing a future value.

Make serving paths explicit

Separate online lookup and historical join endpoints keep low-latency inference retrieval distinct from training-data construction.

Test against a reference

38 test cases cover registry validation, Parquet round trips, and join rules. A seeded randomized test compares the batched join with a naive reference on shuffled data, equal timestamps, gaps, and exact TTL boundaries. CI fails if any test is skipped.

Results & evidence

Which snapshot the historical join picks

TTL window: 24 h before the event Prediction event −24 h t Too oldoutside TTL Eligible,but older Selected:newest ≤ event Futurerejected
For each request event, the historical join keeps the newest hourly snapshot at or before the event time and at most 24 hours old (the registry TTL). An event with no eligible snapshot keeps missing features. Timestamps are illustrative.

Core guarantee

No future rows

Enforced by explicit timestamp and TTL checks in the historical join and checked against a naive reference implementation; an implementation property, not a performance benchmark.

Storage paths

Offline + online

Parquet for historical retrieval and Redis for online lookup, with a shared registry.

Results are documented in the linked project artifacts. They have not been independently reproduced for this portfolio.

Limits & lessons

Each historical request still scans the whole Parquet file in batches, so query cost grows with history size. The API is a local development server without authentication. The Spark timing (2.29–2.43 s for 9.55 million rows on an Apple M4) measures batch aggregation, not historical-join latency or online-serving capacity.

Training-serving consistency requires explicit time semantics, not just matching column names.

Source material