Contents

Chapter 1

Feast Integration Guide

Setting Up Feast

bash
pip install feast
feast init my_features
cd my_features

Feature Definition Pattern

python
from feast import Entity, FeatureView, FileSource, Field
from feast.types import Float32, Int64
from datetime import timedelta

customer = Entity(name="customer_id", join_keys=["customer_id"])

customer_source = FileSource(
    path="data/customer_features.parquet",
    timestamp_field="event_timestamp",
)

customer_fv = FeatureView(
    name="customer_features",
    entities=[customer],
    ttl=timedelta(days=1),
    schema=[
        Field(name="lifetime_value", dtype=Float32),
        Field(name="total_orders", dtype=Int64),
    ],
    source=customer_source,
)

Materializing Features

bash
# Initial materialization
feast materialize 2024-01-01T00:00:00 2024-12-31T00:00:00

# Incremental (from last run to now)
feast materialize-incremental $(date -u +%Y-%m-%dT%H:%M:%S)

Retrieving Features

python
from feast import FeatureStore
store = FeatureStore(repo_path=".")

# Online (for serving)
features = store.get_online_features(
    features=["customer_features:lifetime_value"],
    entity_rows=[{"customer_id": 123}],
)

# Offline (for training)
training_df = store.get_historical_features(
    entity_df=entity_df,
    features=["customer_features:lifetime_value"],
)
Chapter 2

Feature Store Setup Guide

Quick Start

bash
pip install -r requirements.txt
python -c "
from src.feature_registry import FeatureRegistry, FeatureType
reg = FeatureRegistry('./my_registry')
reg.register('user_age', FeatureType.INT, 'user_id', description='User age in years')
print(reg.list_features())
"

Architecture Overview

┌──────────────┐     ┌──────────────┐     ┌──────────────┐
│ Data Sources │ ──> │Materialization│ ──> │ Feature Store │
│ (tables, etc)│     │    Jobs       │     │              │
└──────────────┘     └──────────────┘     ├──────────────┤
                                          │ Offline Store │ <── Training
                                          │ (Parquet/BQ)  │
                                          ├──────────────┤
                                          │ Online Store  │ <── Serving
                                          │ (Redis/dict)  │
                                          └──────────────┘

Key Concepts

  • Feature Registry: Central catalog of all features with metadata
  • Offline Store: Historical feature values for training (batch reads)
  • Online Store: Latest feature values for inference (low-latency)
  • Point-in-Time Join: Join features to events without data leakage
  • Materialization: Computing and writing feature values on a schedule

Migrating to Feast

This toolkit includes a reference implementation that runs with zero

infrastructure. When you're ready for production, swap in Feast:

1. Install Feast: pip install feast

2. Copy configs/feast_feature_store.yaml to your repo

3. Adapt configs/feast_feature_repo.py with your feature definitions

4. Run feast apply to register features

5. Run feast materialize-incremental to compute features

Feature Store Setup Guide v1.0.0 — Free Preview