By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
Topic: Vertex AI Feature Store, Real-Time vs. Batch Feature Engineering
Feature engineering is the process of transforming raw data into meaningful inputs (features) for ML models. In production ML systems, features must be consistent (same values in training and serving), reusable (across models), and low-latency (for real-time predictions). Vertex AI Feature Store is GCP’s managed service for storing, sharing, and serving features at scale, eliminating the need to recompute features for every model.
Real-world scenario:A ride-hailing app (like Uber) needs to predict ETA (Estimated Time of Arrival) in real time. Features like traffic conditions, driver location, and historical trip durations must be: - Precomputed in batch (e.g., daily averages) for training.- Served in real time (e.g., live traffic updates) for inference.- Shared across multiple models (ETA, surge pricing, fraud detection).Vertex AI Feature Store solves this by storing features in a centralized, versioned repository with online (low-latency) and offline (batch) serving.
Vertex AI Feature Store GCP’s managed feature store for storing, sharing, and serving ML features at scale. Supports batch (offline) and real-time (online) feature retrieval with built-in versioning, monitoring, and access control.
Feature Group (EntityType in Vertex AI) A logical container for features related to a specific entity (e.g., user, ride, product). Each feature group has:
user
ride
product
user_id
avg_trip_duration
last_login_time
Online/offline serving configs (e.g., TTL, indexing).
Online vs. Offline Feature Serving
Offline (batch): High-throughput feature retrieval for training. Uses BigQuery or Cloud Storage.
Feature Registry A catalog of feature definitions (metadata) in Vertex AI Feature Store. Ensures consistency across teams (e.g., "What’s the definition of user_credit_score?).
user_credit_score
Feature Monitoring Vertex AI’s built-in drift detection (e.g., mean/median shifts, missing values) to alert when features deviate from training data.
BigQuery ML (for batch feature engineering) Run SQL-based feature transformations directly in BigQuery (e.g., CREATE MODEL for time-series features) without moving data.
CREATE MODEL
Dataflow (Apache Beam) GCP’s serverless stream/batch processing service for real-time feature computation (e.g., aggregating live sensor data).
Pub/Sub + Cloud Functions Lightweight event-driven pipelines for real-time feature updates (e.g., updating user_last_active_time when a user logs in).
user_last_active_time
Vertex AI Pipelines Orchestrates feature engineering workflows (e.g., "Run Dataflow job → update Feature Store → trigger training").
Feature Store vs. Data Warehouse (BigQuery)
BigQuery: Optimized for analytics and batch feature computation (offline).
Feature Drift When feature distributions change over time (e.g., user_income shifts due to inflation), leading to model degradation. Vertex AI Feature Monitoring detects this.
user_income
You’re building a recommendation system for an e-commerce site. Features like user_purchase_history, product_popularity, and user_session_duration must be: - Computed daily (batch) for training.- Served in real time (online) for recommendations.
user_purchase_history
product_popularity
user_session_duration
avg_purchase_value
last_purchase_time
favorite_category
product_id
daily_views
avg_rating
```python from google.cloud import aiplatform
# Initialize Vertex AI aiplatform.init(project="your-project", location="us-central1")
# Create User Feature Group user_feature_group = aiplatform.FeatureGroup.create( display_name="user_features", entity_type="user", online_store_fixed_node_count=1, # For online serving ) ```
Streaming (real-time):
python (pipeline | "Read from Pub/Sub" >> beam.io.ReadFromPubSub(topic="projects/your-project/topics/user_events") | "Parse JSON" >> beam.Map(lambda x: json.loads(x)) | "Update Feature Store" >> beam.ParDo(UpdateFeatureStoreDoFn()) )
Register Features in the Feature Registry
Example: python user_feature_group.create_feature( feature_id="avg_purchase_value", value_type="DOUBLE", description="Average purchase value in the last 30 days", )
python user_feature_group.create_feature( feature_id="avg_purchase_value", value_type="DOUBLE", description="Average purchase value in the last 30 days", )
Enable Online Serving
Example: python user_feature_group.deploy_online_store( fixed_node_count=1, # Adjust for scale sync=True, )
python user_feature_group.deploy_online_store( fixed_node_count=1, # Adjust for scale sync=True, )
Query Features for Training (Offline)
Use BigQuery to fetch historical features for training: sql SELECT user_id, avg_purchase_value, last_purchase_time FROM `your-project.aiplatform_featurestore.user_features` WHERE timestamp BETWEEN TIMESTAMP("2023-01-01") AND TIMESTAMP("2023-12-31")
sql SELECT user_id, avg_purchase_value, last_purchase_time FROM `your-project.aiplatform_featurestore.user_features` WHERE timestamp BETWEEN TIMESTAMP("2023-01-01") AND TIMESTAMP("2023-12-31")
Query Features for Inference (Online)
Use Vertex AI SDK to fetch features in real time: ```python from google.cloud import aiplatform_v1
client = aiplatform_v1.FeaturestoreOnlineServingServiceClient() response = client.fetch_feature_values( featurestore="projects/your-project/locations/us-central1/featurestores/your-featurestore", entity_type="user", entity_id="user123", ) print(response.feature_values) ```
Monitor Feature Drift
When to use Dataflow vs. BigQuery ML?
Key Constraints
Feature Group limits: 1000 features per group, 1000 groups per project.
"Which Service?" Scenarios
Q: A data scientist wants to compute rolling averages for time-series features. What’s the easiest tool? A: BigQuery ML (SQL-based window functions).
Tricky Questions
user_transaction_history
device_location
Why: It provides low-latency feature retrieval for real-time inference.
A retail company wants to compute daily_product_popularity for a recommendation model. The data is in BigQuery, and the team prefers SQL. Which GCP service should they use?
daily_product_popularity
Why: It allows SQL-based feature engineering without moving data.
A gaming company updates player_level in real time when users complete quests. Which GCP service should they use to ingest these updates into Vertex AI Feature Store?
player_level
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.