Implementing a feature store

Optionally, you can use a feature store to address common challenges in machine learning (ML) workflows. You can set up a local feature store with the fraud detection data set.

Using machine learning features for training and inference

The Fraud Detection training notebook, 1_experiment_train.ipynb, loads features with the following code:

df = pd.read_csv('data/train.csv')
X_train = df.iloc[:, [1, 2, 4, 5, 6]].values

In the REST Inference for model server deployment notebook, 3_rest_requests.ipynb, the same features are manually constructed with the following code:

data = [0.3111400080477545, 1.9459399775518593, 1.0, 0.0, 0.0]

The notebooks use completely disconnected code paths for the same features. Consider the following scenario:

You want to add distance_from_home as a sixth feature to improve the model. You update the training notebook to include column index 0 in feature_indexes, retrain the model, and deploy it. But the inference code in 3_rest_requests.ipynb still sends only five values — nobody updated the feature vector construction there. The model now receives a [1, 5] shaped input when it expects [1, 6], and the REST call either crashes or silently maps the wrong values to the wrong features, producing incorrect fraud predictions in production.

This issue is an example of training/serving skew — a class of bugs where the features used during training differ from those used during inference. It is one of the most common and hardest-to-debug issues in production ML systems.

What is Feature Store?

Feature Store in Red Hat OpenShift AI is based on the Feast open-source project. The Feature Store central feature registry provides a single place to define, discover, and manage features. It offers the following capabilities:

  • Historical feature retrieval — Get point-in-time correct features for training.

  • Online feature serving — Get low-latency features for real-time inference.

  • Feature services — Curate different feature sets for different models or teams.

The following table describes the key Feature Store concepts used in this workshop:

Concept Description

Entity

The key used to look up features (for example, a transaction ID or customer ID).

Feature View

A group of related features from a single data source.

Feature Service

A curated set of features for a specific model or use case.

Offline Store

Storage for historical feature data (used for training).

Online Store

Low-latency storage of the latest feature values (used for inference).