Fatskills
Practice. Master. Repeat.
Study Guide: Cloud ML - Google Cloud Professional Machine Learning Engineer: Feature Engineering (Vertex AI Feature Store, Real‑time vs Batch)
Source: https://www.fatskills.com/machine-learning-101/chapter/cloud-ml-cert-gcp-ml-feature-engineering-vertex-ai-feature-store-realtime-vs-batch

Cloud ML - Google Cloud Professional Machine Learning Engineer: Feature Engineering (Vertex AI Feature Store, Real‑time vs Batch)

By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.

⏱️ ~7 min read

GCP_ML – Feature Engineering (Vertex AI Feature Store, Real‑time vs Batch)


Google Cloud Professional Machine Learning Engineer – Feature Engineering Study Guide

Topic: Vertex AI Feature Store, Real-Time vs. Batch Feature Engineering


What This Is

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.


Key Terms & Services

  • 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:

  • A primary key (e.g., user_id).
  • Features (e.g., avg_trip_duration, last_login_time).
  • Online/offline serving configs (e.g., TTL, indexing).

  • Online vs. Offline Feature Serving

  • Online (real-time): Low-latency feature retrieval (e.g., <100ms) for inference. Uses Bigtable under the hood.
  • 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?).

  • 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.

  • 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).

  • Vertex AI Pipelines
    Orchestrates feature engineering workflows (e.g., "Run Dataflow job → update Feature Store → trigger training").

  • Feature Store vs. Data Warehouse (BigQuery)

  • Feature Store: Optimized for low-latency ML serving (online) and feature reuse.
  • 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.


Step-by-Step: Setting Up Vertex AI Feature Store


Scenario:

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.

Steps:

  1. Define Feature Groups (EntityTypes)
  2. Create a Feature Group for user (primary key: user_id) with features:
    • avg_purchase_value (float)
    • last_purchase_time (timestamp)
    • favorite_category (string)
  3. Create a Feature Group for product (primary key: product_id) with features:
    • daily_views (int)
    • avg_rating (float)

```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
)
```


  1. Ingest Features (Batch or Streaming)
  2. Batch (offline):
    • Use BigQuery ML or Dataflow to compute features (e.g., avg_purchase_value from transaction logs).
    • Write to Feature Store via BigQuery export or Vertex AI SDK.
  3. Streaming (real-time):


    • Use Pub/Sub + Dataflow to update last_purchase_time in real time.
    • Example Dataflow pipeline:
      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())
      )
  4. Register Features in the Feature Registry

  5. Define feature metadata (name, type, description, owner) to ensure consistency.
  6. Example:
    python
    user_feature_group.create_feature(
    feature_id="avg_purchase_value",
    value_type="DOUBLE",
    description="Average purchase value in the last 30 days",
    )

  7. Enable Online Serving

  8. Deploy the Feature Group to online store (Bigtable-backed).
  9. Configure TTL (Time-to-Live) for features (e.g., last_purchase_time expires after 24h).
  10. Example:
    python
    user_feature_group.deploy_online_store(
    fixed_node_count=1, # Adjust for scale
    sync=True,
    )

  11. Query Features for Training (Offline)

  12. 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")

  13. Query Features for Inference (Online)

  14. 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) ```

  15. Monitor Feature Drift

  16. Set up Vertex AI Feature Monitoring to alert on:
    • Missing values (e.g., last_purchase_time is null for 20% of users).
    • Distribution shifts (e.g., avg_purchase_value mean increases by 30%).

Common Mistakes

Mistake Correction
Storing raw data in Feature Store Feature Store is for precomputed features, not raw data. Use BigQuery/Cloud Storage for raw data, then transform into features.
Using Feature Store for non-ML use cases Feature Store is optimized for ML serving, not analytics. For dashboards, use BigQuery/Looker.
Not setting TTL for real-time features Features like last_login_time should expire (e.g., TTL=24h) to avoid stale data.
Overlooking online/offline sync Features must be consistent between training (offline) and serving (online). Use Vertex AI Feature Store sync to ensure this.
Ignoring feature drift Enable Feature Monitoring to detect shifts (e.g., user_income distribution changes). Retrain models if drift exceeds thresholds.


Certification Exam Insights

  1. Service Selection Traps
  2. When to use Vertex AI Feature Store vs. BigQuery?
    • Feature Store: Low-latency ML serving (online), feature reuse across models.
    • BigQuery: Batch feature computation, analytics, and training data prep.
  3. When to use Dataflow vs. BigQuery ML?


    • Dataflow: Real-time feature computation (streaming).
    • BigQuery ML: Batch feature engineering (SQL-based).
  4. Key Constraints

  5. Online store latency: ~10–100ms (Bigtable-backed).
  6. Offline store throughput: Depends on BigQuery/Cloud Storage.
  7. Feature Group limits: 1000 features per group, 1000 groups per project.

  8. "Which Service?" Scenarios

  9. Q: A team needs to share features across 10 models with sub-100ms latency. What should they use?
    A: Vertex AI Feature Store (online serving).
  10. 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).

  11. Tricky Questions

  12. Q: Can you use Vertex AI Feature Store for non-ML use cases (e.g., dashboards)?
    A: No. Feature Store is optimized for ML serving, not analytics. Use BigQuery instead.
  13. Q: What happens if you update a feature in online store but not offline store?
    A: Feature drift occurs, leading to training-serving skew. Always sync offline/online stores.

Quick Check Questions

  1. A fintech company needs to detect fraud in real time. Features like user_transaction_history and device_location must be served with <50ms latency. Which GCP service should they use?
  2. Answer: Vertex AI Feature Store (online serving).
  3. Why: It provides low-latency feature retrieval for real-time inference.

  4. 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?

  5. Answer: BigQuery ML.
  6. Why: It allows SQL-based feature engineering without moving data.

  7. 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?

  8. Answer: Dataflow (Apache Beam).
  9. Why: It supports streaming feature updates from Pub/Sub to Feature Store.

Last-Minute Cram Sheet

  1. Vertex AI Feature Store = Managed feature store for ML feature reuse (online + offline serving).
  2. Online store = Bigtable-backed, <100ms latency for real-time inference.
  3. Offline store = BigQuery/Cloud Storage, high-throughput for training.
  4. Feature Group = Container for features related to an entity (e.g., user, product).
  5. Feature Registry = Catalog of feature metadata (name, type, description).
  6. TTL (Time-to-Live) = Expiration time for features (e.g., last_login_time expires after 24h).
  7. Feature Drift = When feature distributions change over time (detected via Vertex AI Feature Monitoring).
  8. BigQuery ML = SQL-based batch feature engineering (e.g., CREATE MODEL for time-series features).
  9. Dataflow = Streaming feature computation (e.g., real-time aggregations).
  10. ⚠️ Feature Store ≠ Data Warehouse – Use BigQuery for analytics, Feature Store for ML serving.
  11. ⚠️ Always sync online/offline stores to avoid training-serving skew.
  12. ⚠️ Feature Store is not for raw data – Precompute features before ingestion.


ADVERTISEMENT