Chapter 7. Use machine learning features
You can distribute the training of a machine learning model across many CPUs by using by using Ray or the Training Operator.
7.1. Understand Feature Store concepts Copy linkLink copied to clipboard!
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.
7.1.1. Use machine learning features for training and inference Copy linkLink copied to clipboard!
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_homeas a sixth feature to improve the model. You update the training notebook to include column index0infeature_indexes, retrain the model, and deploy it. But the inference code in3_rest_requests.ipynbstill 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.
7.1.2. What is Feature Store? Copy linkLink copied to clipboard!
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 tutorial:
| 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). |
7.2. Set up a local feature store Copy linkLink copied to clipboard!
In the Implementing features with Feature Store notebook, 8_feature_store_feast.ipynb, you use Feature Store in local mode, with a SQLite-based registry and online store and a file-based offline store, which requires no external infrastructure.
The Fraud Detection tutorial is not intended for a production environment. The 8_feature_store_feast.ipynb notebook uses local mode as a fully functional alternative.
For information on using Feature Store in a production environment, see Configuring Feature Store.
Prerequisites
- You have imported the tutorial files into your JupyterLab environment as described in Import tutorial files.
-
You have run the
1_experiment_train.ipynbnotebook and it produces theartifact/scaler.pkl.
Procedure
In your JupyterLab environment, open the
8_feature_store_feast.ipynbfile and follow the instructions in the notebook.The notebook guides you through the following tasks:
-
Install the
feastPython package. - Prepare a 10,000-row data subset with entity IDs and timestamps (required by Feature Store).
- Configure a local Feature Store instance.
- Define feature views and a feature service.
- Apply the definitions to the Feature Store registry.
- Materialize features to the online store.
- Retrieve historical features (training use case) and verify data integrity.
- Retrieve online features (inference use case).
- Integrate Feature Store features with the fraud detection model.
-
Install the