Bird
Raised Fist0
MLOpsdevops~10 mins

Feast feature store basics in MLOps - Commands & Configuration

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Introduction
When building machine learning models, you need a way to store and reuse data features safely and quickly. Feast is a tool that helps you organize, store, and serve these features so your models get consistent data during training and prediction.
When you want to share features between different ML models without duplicating data.
When you need to keep feature data fresh and consistent between training and serving.
When you want to simplify feature management and avoid errors from manual data handling.
When you want to serve features in real-time for online predictions.
When you want to track feature definitions and changes over time.
Config File - feature_store.yaml
feature_store.yaml
project: my_project
registry: data/registry.db
provider: local
online_store:
  local:
    path: data/online_store.db

This file sets up the Feast feature store configuration.

  • project: Names your feature store project.
  • registry: Path to the registry file that tracks feature definitions.
  • provider: Specifies where Feast runs; here it is local for simplicity.
  • online_store: Defines where real-time features are stored; here a local database.
Commands
This command creates a new Feast feature store project folder named 'my_feature_repo' with default files to start defining features.
Terminal
feast init my_feature_repo
Expected OutputExpected
Created new Feast repository at my_feature_repo
Change directory into the new feature store project to work on feature definitions and configurations.
Terminal
cd my_feature_repo
Expected OutputExpected
No output (command runs silently)
This command registers the feature definitions and creates the online store tables based on your config and feature files.
Terminal
feast apply
Expected OutputExpected
Applying feature store... Feature sets applied successfully.
This command loads historical feature data from offline storage into the online store for the given date range, making features ready for online serving.
Terminal
feast materialize 2023-01-01T00:00:00 2023-01-02T00:00:00
Expected OutputExpected
Materializing features from 2023-01-01T00:00:00 to 2023-01-02T00:00:00 Materialization complete.
Fetches the latest feature values for the given entity from the online store, useful for real-time model predictions.
Terminal
feast get-online-features --feature-refs=my_feature_set:feature1 --entity-rows='[{"entity_id": 123}]'
Expected OutputExpected
entity_id: 123 feature1: 42.0
Key Concept

If you remember nothing else from Feast, remember: it keeps your ML features consistent and ready for both training and real-time prediction.

Code Example
MLOps
from feast import FeatureStore

store = FeatureStore(repo_path=".")

# Define entity rows to fetch features for
entity_rows = [{"entity_id": 123}]

# Fetch online features
online_features = store.get_online_features(
    feature_refs=["my_feature_set:feature1"],
    entity_rows=entity_rows
).to_dict()

print(f"Feature value for entity 123: {online_features['feature1'][0]}")
OutputSuccess
Common Mistakes
Not running 'feast apply' after changing feature definitions
The online store and registry won't update, so your changes won't take effect.
Always run 'feast apply' after editing feature files to register changes.
Using inconsistent feature data between training and serving
This causes your model to see different data formats or values, reducing accuracy.
Use Feast to serve the same features for training and online prediction to keep data consistent.
Not materializing features before online serving
The online store will not have the latest feature data, causing missing or stale values.
Run 'feast materialize' regularly to load fresh data into the online store.
Summary
Initialize a Feast project with 'feast init' to start managing features.
Use 'feast apply' to register feature definitions and prepare the online store.
Load fresh feature data into the online store with 'feast materialize' for real-time use.
Fetch features for prediction using 'feast get-online-features' or the Python SDK.

Practice

(1/5)
1. What is the main purpose of Feast in machine learning workflows?
easy
A. To store and serve ML features consistently for training and serving
B. To train machine learning models automatically
C. To visualize data trends over time
D. To deploy ML models to production servers

Solution

  1. Step 1: Understand Feast's role

    Feast is designed to store and serve features, not to train or deploy models.
  2. Step 2: Identify the correct purpose

    It ensures features used in training and serving are consistent and reusable.
  3. Final Answer:

    To store and serve ML features consistently for training and serving -> Option A
  4. Quick Check:

    Feast = feature store for consistent features [OK]
Hint: Remember Feast is about features, not models or visualization [OK]
Common Mistakes:
  • Confusing Feast with model training tools
  • Thinking Feast deploys models
  • Assuming Feast is for data visualization
2. Which Feast command is used to fetch features for a given entity ID?
easy
A. feast apply
B. feast online-get
C. feast deploy
D. feast materialize

Solution

  1. Step 1: Review Feast commands

    feast apply sets up feature definitions, materialize loads data, deploy is not a Feast command.
  2. Step 2: Identify fetch command

    feast online-get is used to fetch features for specific entity IDs.
  3. Final Answer:

    feast online-get -> Option B
  4. Quick Check:

    Fetch features = online-get [OK]
Hint: Fetch features? Use online-get command [OK]
Common Mistakes:
  • Using feast apply to fetch features
  • Confusing materialize with fetching
  • Assuming deploy is a Feast command
3. Given this Python snippet using Feast client:
features = client.get_online_features(
    feature_refs=["driver:conv_rate", "driver:acc_rate"],
    entity_rows=[{"driver_id": 1001}]
).to_dict()
print(features)
What will be the output type of features?
medium
A. A dictionary with feature names as keys and lists of values
B. A list of feature names only
C. A string representation of features
D. An integer count of features fetched

Solution

  1. Step 1: Understand get_online_features output

    The method returns an object that can be converted to a dictionary with to_dict().
  2. Step 2: Analyze the dictionary structure

    The dictionary keys are feature names, and values are lists of feature values for each entity row.
  3. Final Answer:

    A dictionary with feature names as keys and lists of values -> Option A
  4. Quick Check:

    to_dict() output = dict of feature lists [OK]
Hint: to_dict() returns dict with feature keys and value lists [OK]
Common Mistakes:
  • Expecting a list instead of dict
  • Thinking output is a string
  • Assuming output is a count number
4. You run feast online-get but get an error: Entity ID not found. What is the most likely cause?
medium
A. The Feast CLI is not installed
B. The feature references are misspelled
C. The feature store is offline
D. The entity ID used does not exist in the feature store

Solution

  1. Step 1: Understand the error message

    'Entity ID not found' means the requested entity ID is missing in the store.
  2. Step 2: Check other options

    CLI not installed or store offline would cause different errors; misspelled features cause feature errors, not entity ID errors.
  3. Final Answer:

    The entity ID used does not exist in the feature store -> Option D
  4. Quick Check:

    Entity ID error = missing entity ID [OK]
Hint: Entity ID error means ID missing in store, not CLI or spelling [OK]
Common Mistakes:
  • Assuming CLI is missing
  • Blaming feature names for entity ID errors
  • Thinking store is offline without checking
5. You want to keep training and serving data consistent using Feast. Which two steps should you perform? Select the best pair.
hard
A. Fetch features randomly during serving, then define features later
B. Train model first, then define features in Feast after training
C. Define features in Feast, then fetch features by entity IDs during serving
D. Store raw data only, and transform features outside Feast

Solution

  1. Step 1: Understand Feast's role in consistency

    Feast ensures features are defined once and reused for training and serving.
  2. Step 2: Identify correct workflow

    Defining features first and fetching by entity IDs during serving keeps data consistent.
  3. Final Answer:

    Define features in Feast, then fetch features by entity IDs during serving -> Option C
  4. Quick Check:

    Define then fetch = consistent features [OK]
Hint: Define features first, fetch by entity IDs for consistency [OK]
Common Mistakes:
  • Training before defining features
  • Fetching features randomly
  • Ignoring Feast for feature transformations