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

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

  1. 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
    Copy to Clipboard Toggle word wrap

    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:
    Copy to Clipboard Toggle word wrap

Verification

Run the following feast commands to verify that the feature data is in the online store:

$ feast feature-views list
Copy to Clipboard Toggle word wrap

Example output:

NAME          	ENTITIES 	TYPE
zipcode_features  {'zipcode'}  FeatureView
credit_history	{'dob_ssn'}  FeatureView
total_debt_calc   {'dob_ssn'}  OnDemandFeatureView
Copy to Clipboard Toggle word wrap
$ feast entities list
Copy to Clipboard Toggle word wrap

Example output:

Output:
NAME 	DESCRIPTION   	TYPE
zipcode               ValueType.INT64
dob_ssn  Date of birth and last four digits of social security number  ValueType.STRING
Copy to Clipboard Toggle word wrap

4.2. Retrieving online features for model inference

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

  1. From the OpenShift AI dashboard, click Data science projects.
  2. Click the name of the project and then click the Workbenches tab.
  3. Click the open icon ( The open icon ) next to the workbench.
  4. 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('.')
    Copy to Clipboard Toggle word wrap
  5. Identify the feature service:

    feature_service = feature_store.get_feature_service("credit_activity")
    Copy to Clipboard Toggle word wrap
  6. Retrieve features from the online store by using the get_online_features method:

    features = feature_store.get_online_features(
    features=feature_service,
        entity_rows=[
            # {join_key: entity_value}
            {"dob_ssn": 19530219_5179},
            {"dob_ssn": 19500806_6783},
        ]
    )
    Copy to Clipboard Toggle word wrap

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]
}
Copy to Clipboard Toggle word wrap

Next step

Volver arriba
Red Hat logoGithubredditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar. Explore nuestras recientes actualizaciones.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

Theme

© 2025 Red Hat