# ML Framework and Google Cloud AI/ML Overview

> Chapter 1 of the Courseiva GOOGLE-PMLE curriculum — https://courseiva.com/learn/google-pmle/ml-framework-overview

**Official objective:** 1.1 — Define the stages of the ML workflow and how they map to Google Cloud services.

## Introduction

The ML workflow defines the structured, repeatable steps that turn raw data into a functioning machine learning model. Understanding this workflow and how Google Cloud services support each stage is essential for the PMLE exam because questions frequently test your ability to map specific services to the correct phase of the workflow, not just to memorise service names.

## The Catering Kitchen Analogy

A large commercial catering kitchen is a perfect analogy for the ML workflow and Google Cloud AI/ML services. The kitchen's central worktable is the ML framework, like TensorFlow or PyTorch, where all the core ingredients are assembled and processed. The raw ingredients delivered each morning are the raw data, arriving from multiple suppliers (Google Cloud Storage, BigQuery). The head chef's first task is ingredient inspection and preparation, which is data validation and preprocessing using Cloud Data Fusion or Dataprep — trimming bad edges, washing dirt off, and chopping everything into uniform pieces. The prepared ingredients are then measured and combined according to a specific recipe, which is the model training step using Vertex AI Training. The oven, set to precise time and temperature, is the compute resource — the GPUs and TPUs provided by Google Compute Engine that bake the model. After baking, the chef tastes the dish and adjusts seasoning, which is model evaluation and hyperparameter tuning with Vertex AI Vizier. Once perfected, the dish is plated and sent to the dining room via a heated pass, which is model deployment using Vertex AI Prediction and Endpoints. Finally, the restaurant's point-of-sale system tracks which dishes are ordered most and sends feedback to the chef, which is model monitoring and retraining with Vertex AI Model Monitoring. Every piece of equipment and role in this kitchen maps directly to a specific Google Cloud service in the ML lifecycle.

The key insight is that no single appliance works in isolation — the workflow is a connected pipeline from raw data to operational model, just like a full-service kitchen moves ingredients from delivery to customer table.

## Core explanation

Machine learning (ML) is a way of teaching computers to make predictions or decisions without being explicitly programmed for every scenario. Instead of writing a rule like “if the email contains the word ‘free’, mark it as spam,” you show the computer thousands of examples of spam and non-spam emails, and it figures out the patterns itself. The ML workflow is the standard pipeline of stages you follow to build, deploy, and maintain such a system.

The first stage is **problem definition and data collection**. Before you write any code, you must clearly define what you want to predict (the business problem) and gather the raw data that might help make that prediction. For a property valuation model, you would collect historical sale prices, square footage, location, and number of bedrooms. On Google Cloud, this often uses Cloud Storage (object storage for any file type) or BigQuery for structured tabular data.

The second stage is **data preparation and pre-processing**. Raw data is almost never ready to feed directly into a model. It contains missing values (gaps in the data), outliers (extreme values that skew results), and inconsistent formatting (e.g., ‘London’ vs ‘london’). You must clean, normalise, and transform the data into a structured format the model can understand, typically a numerical table. Google Cloud services for this include Dataproc (managed Hadoop/Spark for large-scale processing) and Dataflow (stream and batch data processing based on Apache Beam).

The third stage is **model training**. Here, you choose a machine learning algorithm and feed it your prepared data. The algorithm adjusts internal parameters to minimise the error between its predictions and the actual outcomes. On Google Cloud, Vertex AI Training provides managed infrastructure with GPUs (Graphics Processing Units, specialised for parallel computation) and TPUs (Tensor Processing Units, Google’s custom-designed chips for speeding up ML training). You can also use Colab, a notebook environment, for smaller experiments.

The fourth stage is **model evaluation and tuning**. You hold back a portion of your data that the model has never seen, called a test set, and measure how well it predicts on that set. Metrics like accuracy, precision, and recall tell you if your model is any good. If it performs poorly, you adjust hyperparameters (settings that control the learning process, like learning rate) and retrain. Vertex AI Vizier helps automate this hyperparameter tuning.

The fifth stage is **model deployment and serving**. Once the model is good enough, you make it available for others to use. This often means deploying it as an API endpoint that applications can call. Vertex AI Prediction handles this, scaling the infrastructure up and down based on demand (called elastic scaling).

The sixth stage is **model monitoring and management**. After deployment, models can degrade over time because real-world data changes (known as data drift or concept drift). You must monitor model performance, detect when it is slipping, and retrain it with fresh data. Vertex AI Model Monitoring automates this detection.

The final, often overlooked stage is **ML orchestration**. You need a system to tie all these stages together into a repeatable pipeline. This is Machine Learning Operations, or MLOps. On Google Cloud, Vertex AI Pipelines lets you define the entire workflow as code so it runs automatically on a schedule or when new data arrives.

A critical concept here is the difference between **structured** data (rows and columns, like a spreadsheet) and **unstructured** data (images, text, audio). Google Cloud services handle both: Cloud Vision AI for image analysis, Natural Language AI for text, and AutoML for automatically building models without deep ML expertise.

In summary, the ML workflow is not a one-time project but an ongoing cycle of continuous improvement, and Google Cloud provides a service for every step to make this cycle efficient and scalable.

## Real-world context

Sarah is a data engineer at a large retail company that sells clothing online. Her team has been given a project: build a model that predicts which customers are likely to make a purchase within the next seven days, so the marketing team can send targeted promotions. Sarah must navigate the entire ML workflow using Google Cloud.

First, she defines the problem with her stakeholders. The prediction target is a binary outcome — ‘will buy’ or ‘will not buy’. The data sources include customer profile data from Cloud SQL (a relational database), browsing history stored in BigQuery, and past purchase records also in BigQuery. Sarah gathers all this raw data into a Cloud Storage bucket for processing.

Next, she prepares the data. She uses Dataprep to clean missing values (e.g., customers with no recorded age), normalise the purchase amounts, and merge the three datasets into one flat table. She uses Dataflow to run a pipeline that joins the streams in real time, since the marketing team wants the model to update as customers browse. She splits the final dataset into an 80% training set and a 20% test set, storing both in BigQuery.

For training, Sarah uses Vertex AI Training. She selects a pre-built algorithm called XGBoost (a popular tree-based model) and specifies the training set location. She chooses a machine type with GPUs to speed up training. The model trains and outputs a file containing the learned parameters.

Sarah evaluates the model using Vertex AI Experiments, comparing its predictions against the test set. The model achieves 82% accuracy, but the business wants a very low false positive rate (showing promotions to people who won’t buy). She uses Vertex AI Vizier to tune hyperparameters and retrains, achieving 85% with a better false positive rate.

Now for deployment: Sarah packages the model into a container image and pushes it to the Artifact Registry. She deploys it to Vertex AI Endpoints, creating a REST API that the marketing system can call. She sets up autoscaling so that the endpoint spins up more machines during high-traffic promotion days.

Finally, she sets up monitoring. She uses Vertex AI Model Monitoring to track whether the predictions are becoming less accurate over time. When the quality drops below a threshold, it triggers a retraining pipeline in Vertex AI Pipelines, which automatically pulls fresh data and retrains the model.

Throughout this process, Sarah uses Cloud Logging to track errors and Cloud Monitoring to watch system health. She follows MLOps best practices by versioning her data, code, and model artefacts, ensuring every step is reproducible. The marketing team gets their predictions on time, and the campaign sees a 15% uplift in conversions — all because Sarah mapped each stage of the ML workflow to the correct Google Cloud service.

## Exam focus

The PMLE exam tests Objective 1.1, ‘Define the stages of the ML workflow and how they map to Google Cloud services,’ in several specific ways. The most common question type is scenario-based: you read a description of a problem (e.g., ‘a company has raw CSV files in Cloud Storage and wants to train an image classification model’), and you must select the correct sequence of Google Cloud services that cover the stages from data ingestion to deployment. These are often multiple-choice questions with answer options that list services in the wrong order or include an irrelevant service.

A standard trap the exam sets is misordering the stages. For example, an answer might suggest that model monitoring comes before model training, or that data preparation occurs after deployment. The correct pattern almost always follows this sequence: collect data (Cloud Storage/BigQuery), prepare data (Dataproc/Dataflow), train model (Vertex AI Training), evaluate and tune (Vertex AI Vizier), deploy (Vertex AI Endpoints), and monitor (Vertex AI Model Monitoring). Memorise this timeline.

Another common trap is confusing services that sound similar. For instance, ‘Cloud AutoML’ is now part of ‘Vertex AI’ — the exam may use the old name to trick you. Always look for ‘Vertex AI’ as the umbrella service. Another trap is misattributing a service to the wrong stage. BigQuery is often listed as a data preparation service, but it is primarily for storage and querying; Dataprep and Dataflow are the actual preparation tools.

The exam loves to test your understanding of managed vs. unmanaged services. For example, you might be asked whether to use Compute Engine (unmanaged — you configure the VMs yourself) or Vertex AI Training (managed — Google handles the infrastructure) for a given task. The correct answer is almost always the managed service for ML workloads unless the question specifies custom requirements.

Key definitions to memorise for this exam objective:
- **Data ingestion**: bringing data into the cloud (Cloud Storage, Pub/Sub)
- **Data transformation**: converting raw data into a model-ready format (Dataflow, Dataprep)
- **Training infrastructure**: compute resources for model training (Vertex AI Training, GPUs, TPUs)
- **Hyperparameter tuning**: automatically optimising model settings (Vertex AI Vizier)
- **Model registry**: central repository for versioning trained models (Vertex AI Model Registry)
- **Deployment endpoint**: API endpoint for serving predictions (Vertex AI Endpoints)
- **Model monitoring**: detecting performance decay over time (Vertex AI Model Monitoring)
- **Pipeline orchestration**: automating the entire workflow (Vertex AI Pipelines, Cloud Composer)

You should also be prepared for questions that ask you to diagnose a failing workflow. For instance, a scenario describes that the model trains but the predictions are always wrong. The answer often points to the data preparation stage — perhaps the data was not normalised or the label column was missing.

Finally, the exam may give you a list of stages from a generic ML workflow (like CRISP-DM) and ask you to map them to the Google Cloud equivalent. CRISP-DM stages are: Business Understanding, Data Understanding, Data Preparation, Modeling, Evaluation, Deployment. These map directly to the stages described above, but the exam expects you to recognise that ‘Modeling’ maps to Vertex AI Training, and ‘Evaluation’ maps to Vertex AI Experiments and Vizier.

In summary, to pass this objective: memorise the exact order of stages, know which Google Cloud service belongs to each stage, watch out for old service names and misordered answer options, and always bias toward managed Vertex AI services over raw Compute Engine.

## Step by step

1. **1. Define the Business Problem and Collect Data** — Clearly state what you want to predict (e.g., customer churn) and identify the data sources that might contain relevant signals, such as transaction history and support tickets. On Google Cloud, you might store this data in Cloud Storage for unstructured files or BigQuery for structured tables.
2. **2. Prepare and Preprocess the Data** — Clean the raw data by removing duplicates, handling missing values, and normalising numerical features. Use Dataprep for interactive visual cleaning, Dataflow for large-scale batch/stream processing, or BigQuery SQL for simple transformations. Split the data into training and test sets.
3. **3. Train the Machine Learning Model** — Select an algorithm (e.g., linear regression, XGBoost, or a neural network) and feed the training data into the model using Vertex AI Training. Choose compute resources like GPUs or TPUs based on data size and model complexity. The model learns patterns by adjusting its internal parameters.
4. **4. Evaluate and Tune the Model** — Use the test set to measure model performance with metrics like accuracy, precision, and recall. If performance is poor, adjust hyperparameters (e.g., learning rate, number of trees) using Vertex AI Vizier for automated optimisation. Repeat the train-evaluate cycle until satisfied.
5. **5. Deploy and Serve Predictions** — Package the trained model into a container and deploy it to Vertex AI Endpoints, which creates a REST API for real-time predictions. Configure autoscaling to handle variable traffic loads. Companies use this endpoint to integrate predictions into their applications.
6. **6. Monitor and Retrain** — Set up Vertex AI Model Monitoring to track prediction quality over time. If the model's accuracy drops (indicating drift), trigger an automated retraining pipeline using Vertex AI Pipelines that fetches fresh data, retrains, and redeploys the updated model without manual intervention.

## Comparisons

### Vertex AI Training vs Compute Engine with custom ML setup

**Vertex AI Training:**
- Managed service; Google handles infrastructure, scaling, and security patches.
- Automatically provisions GPUs/TPUs and shuts them down when not in use to save cost.
- Integrated with Vertex AI Pipelines, Model Registry, and Endpoints for seamless MLOps.

**Compute Engine with custom ML setup:**
- Unmanaged; you create and configure virtual machines yourself.
- You must manually manage scaling, patching, and cost optimisation.
- Requires additional setup to integrate with other Vertex AI components.

### Vertex AI (new unified platform) vs Cloud AutoML (old deprecated name)

**Vertex AI (new unified platform):**
- Current Google Cloud brand for all AI/ML services.
- Includes training, evaluation, prediction, pipelines, and monitoring in one interface.
- Tested on the PMLE exam; you should use this term in answers.

**Cloud AutoML (old deprecated name):**
- Old brand name now subsumed under Vertex AI AutoML.
- Was a separate product; now just a feature within Vertex AI.
- Using this term may indicate outdated knowledge to the examiner.

### Dataflow (Apache Beam-based) vs Dataproc (Hadoop/Spark-based)

**Dataflow (Apache Beam-based):**
- Best for streaming data and real-time processing pipelines.
- Serverless; no clusters to manage; automatic scaling.
- Ideal for data transformation during ML data preparation.

**Dataproc (Hadoop/Spark-based):**
- Best for batch processing of large datasets using Spark or Hadoop.
- You manage clusters (or use Dataproc Serverless) for processing.
- Often used for ETL jobs that are not real-time.

### BigQuery ML (BQML) vs Vertex AI Training

**BigQuery ML (BQML):**
- Train models using SQL queries directly inside BigQuery.
- Limited to algorithms supported by BQML (linear regression, XGBoost, etc.).
- Good for quick, simple models on structured data without moving data.

**Vertex AI Training:**
- Train models using Python (TensorFlow, PyTorch, etc.) with custom code.
- Supports any algorithm, including deep learning and custom architectures.
- More complex to set up but necessary for advanced models.

## Diagram

_The stages of the ML workflow from business problem to monitoring, with corresponding Google Cloud services shown under each stage._

```mermaid
flowchart TD
    A[Business Problem] --> B[Data Collection]
    B --> C[Data Preparation]
    C --> D[Model Training]
    D --> E[Evaluation & Tuning]
    E --> F[Deployment]
    F --> G[Monitoring & Feedback]
    G --> C
    B --> B1[Cloud Storage]
    B --> B2[BigQuery]
    C --> C1[Dataprep / Dataflow]
    D --> D1[Vertex AI Training]
    E --> E1[Vertex AI Vizier]
    F --> F1[Vertex AI Endpoints]
    G --> G1[Vertex AI Model Monitoring]
```

## Common misconceptions

- **Misconception:** Once a model is deployed, your job is done and you never need to touch it again. **Reality:** Models degrade over time due to data drift and concept drift, so continuous monitoring and periodic retraining are essential parts of the ML workflow. Vertex AI Model Monitoring exists precisely for this reason. (This misconception comes from traditional software development where a feature is built, tested, and deployed with no further changes expected. ML is fundamentally different because the model's environment changes.)
- **Misconception:** All Google Cloud AI services are separate products that you must integrate manually. **Reality:** Vertex AI is a unified platform that brings together training, prediction, model registry, pipelines, and monitoring into one cohesive interface. You do not need to piece together disparate services. (Google Cloud's marketing history once promoted individual services like Cloud AutoML and AI Platform separately, and many older learning materials reflect that fragmentation.)
- **Misconception:** The order of stages in the ML workflow does not matter as long as you eventually do each one. **Reality:** The stages are strictly sequential because each step depends on the output of the previous one. You cannot evaluate a model before training it, nor can you deploy raw data without preprocessing. (Beginners often approach projects iteratively and in a haphazard order, so they assume the formal workflow is similarly flexible. It is not — the dependency chain is rigid.)
- **Misconception:** BigQuery is just a data warehouse and has no role in ML. **Reality:** BigQuery can store training data, run simple transformations using SQL, and even train models directly using BigQuery ML (BQML) for basic use cases without moving data elsewhere. (BigQuery is often introduced as a data warehousing product, so beginners overlook its ML capabilities. The PMLE exam tests BQML as a valid option for simple, small-scale models.)

## Key takeaways

- The ML workflow follows a strict sequence: problem definition, data collection, data preparation, model training, evaluation, deployment, and monitoring.
- Vertex AI is Google Cloud's unified platform that covers training, prediction, evaluation, pipelines, and model management.
- Data preparation is the most time-consuming stage and the most common source of errors in an ML project.
- Model monitoring is essential because real-world data changes over time, causing model performance to degrade (data drift).
- Hyperparameter tuning using Vertex AI Vizier can significantly improve model accuracy without manual trial and error.
- Google Cloud provides both managed services (Vertex AI) and unmanaged services (Compute Engine); choose managed for lower operational overhead.
- BigQuery ML allows you to train ML models directly from SQL queries, suitable for simple models on structured data.
- Pipeline orchestration with Vertex AI Pipelines makes your ML workflow repeatable, auditable, and automated.

## FAQ

**Do I need to know how to code to use Google Cloud AI services?**

Many services, like AutoML within Vertex AI and BigQuery ML, allow you to train models with minimal or no code using a graphical interface or SQL. However, for the PMLE exam, you need to understand the concepts and service mappings, not write code.

**What is the difference between Vertex AI and Cloud AutoML?**

Vertex AI is the current unified platform that replaced Cloud AutoML and AI Platform. Cloud AutoML is now just a feature set inside Vertex AI called 'Vertex AI AutoML.' The exam tests the current name, so always use 'Vertex AI.'

**What is a pipeline in ML, and why do I need one?**

A pipeline is an automated sequence of steps that processes data, trains a model, evaluates it, and deploys it. You need one to make your workflow repeatable, reduce manual errors, and enable automatic retraining when new data arrives. Vertex AI Pipelines is the service for this.

**Is BigQuery ML the same as Vertex AI?**

No, BigQuery ML is a separate service that lets you train models using SQL directly inside BigQuery. It is best for simple models on structured data. Vertex AI is a more comprehensive platform for complex models, especially those using unstructured data like images and text.

**What does 'monitoring' mean in the ML workflow?**

Monitoring means continuously tracking your deployed model's prediction quality. If real-world data changes (e.g., customer behaviour shifts), the model's accuracy can drop. Vertex AI Model Monitoring detects this drift and can alert you or trigger automatic retraining.

**What is the difference between a GPU and a TPU?**

GPUs (Graphics Processing Units) are general-purpose parallel processors good for many ML models. TPUs (Tensor Processing Units) are custom-built by Google specifically to speed up TensorFlow models, often providing faster training for large neural networks. Vertex AI lets you choose either.

## Check your understanding

1. **What is the correct order of stages in the ML workflow, as tested on the PMLE exam?**

   Answer: The stages are: problem definition, data collection, data preparation, model training, evaluation and tuning, deployment, and monitoring.

2. **Which Google Cloud service is used for hyperparameter tuning during model evaluation?**

   Answer: Vertex AI Vizier.

3. **What is the purpose of Vertex AI Model Monitoring?**

   Answer: It detects when a deployed model's performance degrades over time due to data drift or concept drift, and can trigger automatic retraining.

4. **What is the difference between managed and unmanaged ML services on Google Cloud?**

   Answer: Managed services (like Vertex AI Training) handle infrastructure, scaling, and maintenance automatically, while unmanaged services (like Compute Engine) require you to configure and manage everything yourself.

5. **True or false: Once a model is deployed, you do not need to retrain it. Explain your reasoning.**

   Answer: False. Models must be monitored and retrained periodically because real-world data changes over time, causing model accuracy to drop (data drift).

---

Interactive version with quiz and diagrams: https://courseiva.com/learn/google-pmle/ml-framework-overview
