Lesson 1 of 6 The ML Development Lifecycle and MLOps

Following the Stages of a Machine Learning Pipeline

This lesson explains how a machine learning project moves through a defined pipeline, from a business problem to a monitored model in production, and which AWS services support each stage.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe the stages of a machine learning pipeline in order.
  • Describe common feature engineering techniques.
  • Distinguish hyperparameters from model parameters.
  • Compare the sources of models: open-source pre-trained models, proprietary foundation models and custom models.

The stages in order

A machine learning project moves through a sequence of stages. It begins by defining the problem: which decision the model will support, how success will be measured, and whether ML is the right approach at all. Data is collected, often into Amazon S3, and then prepared: cleaned, de-duplicated, labelled and split, with exploratory data analysis (EDA) to understand its distributions and quality. Feature engineering turns raw data into useful model inputs, such as a customer's number of orders in the last 30 days.

The model is then trained on the training set, tuned by trying different hyperparameter settings and keeping the best on the validation set, and evaluated on the test set, including checks for bias. Finally it is deployed to serve predictions and monitored, so that it can be retrained when its quality falls. The following table summarises the stages and the AWS services that support each.

StageWhat happensAWS support
1. Define the problemDecide which decision the model supports, the success metric, and whether ML is right at all—
2. Collect dataGather data from databases, logs, sensors or third partiesAmazon S3
3. Prepare data and EDAClean, de-duplicate, label, split; explore distributions and qualityGround Truth, Data Wrangler, notebooks
4. Feature engineeringTurn raw data into useful inputsSageMaker Feature Store
5. TrainLearn the model from the training setSageMaker training jobs
6. TuneTry hyperparameter settings; keep the best on the validation setSageMaker Automatic Model Tuning
7. EvaluateMeasure on the test set; check for biasSageMaker Clarify
8. DeployServe from an endpoint or batch jobSageMaker AI hosting
9. Monitor and retrainWatch for drift; retrain when quality fallsSageMaker Model Monitor

The following diagram shows the stages with the AWS service for each.

The stages of a machine learning project with the AWS services that support them. Define the problem and how success is measured; collect data, often into Amazon S3; prepare and explore it; engineer features; train, tune hyperparameters on the validation set and evaluate on the test set, including bias checks with SageMaker Clarify; deploy with SageMaker AI hosting; and monitor with Model Monitor, retraining when quality falls.
Monitoring feeds back into training.
Put in order

The ML pipeline

Exam skills 1.3.1

Put the stages of a machine learning project in order.

Log in to try this activity Interactive activities are free with an account.

Feature engineering

Feature engineering turns raw data into model inputs, for example:

  • Extracting the day of the week from a date.
  • Scaling numbers to similar ranges.
  • Encoding categories as numbers.
  • Combining fields, such as price per square foot.

Storing features in Feature Store lets training and inference use the same definitions.

Match the pairs

Raw data to features

Exam skills 1.3.1

Match each piece of raw data with the feature engineering step that makes it a useful input.

Log in to try this activity Interactive activities are free with an account.

Hyperparameters versus parameters

Hyperparameters and parameters are both settings of a model, but they are set at different times by different parties. Hyperparameters are chosen by you before training starts and control how training works, such as the learning rate, the number of trees in a forest, the number of passes through the data (epochs) and the batch size. Tuning means trying different hyperparameter values to find the best. Parameters are learned by the algorithm during training, such as the weights and biases of a neural network; they are what the trained model actually consists of. The following table summarises the difference.

Hyperparameters
SetBefore training, by you
ExamplesLearning rate, number of trees, epochs, batch size
Parameters
SetDuring training, by the algorithm
ExamplesWeights and biases
Sort into groups

Set or learned?

Exam skills 1.3.1 · 1.3.5

Decide whether each value is a hyperparameter, chosen before training, or a parameter, learned during it.

Log in to try this activity Interactive activities are free with an account.

Where models come from

A model can come from three sources, which trade speed and cost against control. An open-source pre-trained model, from SageMaker JumpStart or Hugging Face, can be used or adapted quickly and cheaply. A proprietary foundation model called through an API, as in Amazon Bedrock, needs no infrastructure at all. A custom model trained on your own data gives the most control and can be tailored exactly to the problem, but it takes the most effort, data and expertise. The following table summarises the options.

SourceTrade-off
Open-source pre-trained model (SageMaker JumpStart, Hugging Face)Fast and cheap
Proprietary foundation model through an API (Amazon Bedrock)No infrastructure
Custom model trained on your dataMost control, most effort
Scenario questions

Where should the model come from?

Exam skills 1.3.2

Choose the source of a model for each situation.

Log in to try this activity Interactive activities are free with an account.
Worked example

Following one project through the pipeline

A delivery company wants to predict late deliveries so it can warn customers. Following the project through each stage shows what happens and which AWS tool helps:

StageIn this project
Define the problemPredict whether a parcel will be late (classification); success = catch 80% of late parcels
Collect dataTwo years of delivery records, weather data and traffic data in Amazon S3
Prepare dataRemove duplicates, fill missing postcodes, label each delivery late or on time (Data Wrangler)
Feature engineeringDay of week, distance, driver's average delay, rain forecast (stored in Feature Store)
Train and tuneTrain a gradient-boosted tree; Automatic Model Tuning tries learning rates and tree depths
EvaluateOn the held-back test set the model catches 84% of late parcels; Clarify checks for regional bias
DeployReal-time endpoint called when each parcel is scanned
MonitorModel Monitor notices accuracy falling at Christmas, when patterns change; the model is retrained

The learning rate and tree depth chosen in tuning are hyperparameters (set before training); the thresholds inside each tree are parameters the algorithm learns.

Check yourself

What is the difference between a hyperparameter and a model parameter?

Show answer

Hyperparameters, such as the learning rate or the number of trees, are set before training. Parameters, such as a network's weights, are learned from the data during training.

Exam Tips

Remember for the exam

  • The stages run: problem definition, data collection, preparation and EDA, feature engineering, training, tuning, evaluation, deployment and monitoring.
  • Creating useful inputs from raw data is feature engineering.
  • Hyperparameters are set before training; parameters are learned during it.
  • To find the best hyperparameters automatically, use SageMaker Automatic Model Tuning.
  • Monitoring and retraining close the loop when data drifts.