Este contenido no está disponible en el idioma seleccionado.
Chapter 4. Retrieving features for model training
After a cluster administrator configures Feature Store on Red Hat OpenShift AI, an ML engineer or a data scientist can retrieve features to train models for inference.
4.1. Making features available for real-time inference Copiar enlaceEnlace copiado en el portapapeles!
To make features available for real-time inference for use by ML engineers and data scientists on your team, load or materialize feature data to the online store.
Materialization ensures that the same features are available for both model training and real-time predictions, making your ML workflow robust and reproducible. The online store serves the latest features to models for online prediction. Data scientists on your team with access to your data science project can access the features in the online store.
Note: Feature Store uses a "push" method for online serving. This means that the Feature Store pushes feature values to the online store, which reduces the latency of feature retrieval. This is more efficient than a "pull" method, where the model serving system would make a request to the Feature Store to retrieve feature values.
Prerequisites
- In your IDE environment, you have installed the Feature Store Python SDK as described in Setting up your working environment.
- Your cluster administrator has pushed feature data to the online store.
- Optionally, you have cloned a Git repository that includes your model training code.
Procedure
To load feature data to the online store, run the
feast materialize
command and specify an historical time range (start and end) for the feature data that you want to load, as shown in the following example:feast materialize 2020-01-01T00:00:00 2022-01-01T00:00:00
$ feast materialize 2020-01-01T00:00:00 2022-01-01T00:00:00
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Feature Store queries the batch sources for all feature views over the provided time range, and loads the latest feature values into the configured online store, as indicated by output similar to the following:
Materializing 2 feature views to 2025-07-23 17:02:13+00:00 into the sqlite online store. zipcode_features from 2015-07-26 17:02:18+00:00 to 2025-07-23 17:02:13+00:00: credit_history from 2025-04-24 17:02:22+00:00 to 2025-07-23 17:02:13+00:00:
Materializing 2 feature views to 2025-07-23 17:02:13+00:00 into the sqlite online store. zipcode_features from 2015-07-26 17:02:18+00:00 to 2025-07-23 17:02:13+00:00: credit_history from 2025-04-24 17:02:22+00:00 to 2025-07-23 17:02:13+00:00:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Run the following feast
commands to verify that the feature data is in the online store:
feast feature-views list
$ feast feature-views list
Example output:
NAME ENTITIES TYPE zipcode_features {'zipcode'} FeatureView credit_history {'dob_ssn'} FeatureView total_debt_calc {'dob_ssn'} OnDemandFeatureView
NAME ENTITIES TYPE
zipcode_features {'zipcode'} FeatureView
credit_history {'dob_ssn'} FeatureView
total_debt_calc {'dob_ssn'} OnDemandFeatureView
feast entities list
$ feast entities list
Example output:
Output: NAME DESCRIPTION TYPE zipcode ValueType.INT64 dob_ssn Date of birth and last four digits of social security number ValueType.STRING
Output:
NAME DESCRIPTION TYPE
zipcode ValueType.INT64
dob_ssn Date of birth and last four digits of social security number ValueType.STRING
4.2. Retrieving online features for model inference Copiar enlaceEnlace copiado en el portapapeles!
After your cluster administrator loads feature data to the online store, you can retrieve features for model training.
When the cluster administrator creates a FeatureStore
CR, by default, it runs the online store feature server. This Python feature server is an HTTP endpoint that serves features with JSON I/O. You can write and read features from the online store by using any programming language that can make HTTP requests.
Note: You can also retrieve online features by using the Feast SDK as described in the upstream Feast documentation.
A feature service is an object that represents a logical group of features from one or more feature views. With a feature service, your ML models can access features from within a feature view as needed.
Typically, you create one feature service per model version, allowing for tracking of the features used by models. The features retrieved from the online store can belong to many feature views.
Note: When you apply a feature service, an actual Feature Store server is not deployed.
Prerequisites
-
In your IDE environment, you have installed the Feature Store Python SDK and added a
feature_store.yaml
file, as described in Setting up your working environment. - Optionally, you have cloned a Git repository that includes your model training code.
- Feature data is loaded in the online store, as described in Making features available for real-time inference.
Procedure
- From the OpenShift AI dashboard, click Data science projects.
- Click the name of the project and then click the Workbenches tab.
-
Click the open icon (
) next to the workbench.
In a Python notebook cell, run the following command to instantiate a local FeatureStore object that can parse the feature registry:
from feast import FeatureStore feature_store = FeatureStore('.')
from feast import FeatureStore feature_store = FeatureStore('.')
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Identify the feature service:
feature_service = feature_store.get_feature_service("credit_activity")
feature_service = feature_store.get_feature_service("credit_activity")
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Retrieve features from the online store by using the
get_online_features
method:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
When you run the feast
commands, you should see output similar to the following:
Example output
{ 'credit_card_due': [833,1297], 'bankruptcies': [0, 1], 'dob_ssn': [19530219_5179, 19500806_6783] }
{
'credit_card_due': [833,1297],
'bankruptcies': [0, 1],
'dob_ssn': [19530219_5179, 19500806_6783]
}
Next step
See the following Git repositories for an example of how to use features to train a model.
https://github.com/feast-dev/feast-credit-score-local-tutorial
https://github.com/feast-dev/feast/tree/stable/examples/operator-quickstart