Hands-On Guide to Amazon SageMaker: Building and Deploying Machine Learning Models

Welcome to this hands-on tutorial where we will explore Amazon Web Services (AWS) SageMaker, a powerful, fully managed machine learning service. SageMaker empowers data scientists and developers to create, train, and deploy machine learning models with ease. In this tutorial, we will walk through the process of setting up SageMaker, creating a dataset, training a machine learning model, and deploying it to a production-ready environment.

Getting Started with SageMaker

Before we dive into the tutorial, ensure you have an AWS account. If not, you can easily sign up for one at aws.amazon.com. Once you have an AWS account, log in to the AWS Management Console.

To follow this tutorial, you’ll need an S3 bucket. If you don’t have one, create it by following these steps:

  1. Click on “Services” in the AWS Console and select “S3.”
  2. Click “Create bucket” and give it a name containing “sagemaker.”
  3. Leave the configuration options to default and proceed to create the bucket.

With your S3 bucket ready, we can now create a SageMaker notebook instance.

Creating a SageMaker Notebook Instance

  1. In the AWS Console, click on “Amazon SageMaker.”
  2. Click “Create notebook instance.”
  3. Enter a name for the notebook instance.
  4. Leave the instance type as “ml.t2.medium.”
  5. Select “Create a new IAM role” and attach your S3 bucket by entering the bucket name.
  6. Click “Create role” and then “Create notebook instance.”

Once the notebook instance is in the “InService” status, click “Open Jupyter” to launch the Jupyter notebook. choose conda_python3 It will open a new Jupiter notebook. Rename “Untitled”

Exploring the SageMaker Tutorial

Now that your SageMaker notebook is running, let’s work through the tutorial. The tutorial uses the MNIST dataset, which consists of 60,000 handwritten single-digit number images. We’ll use the K-means algorithm to group these images into 10 clusters (one for each digit).

  1. First, download the MNIST dataset using Python code provided in the notebook.
  2. Explore the dataset and visualize some images to understand the data.
  3. Next, convert the data into the RecordIO protobuf format, which SageMaker prefers. Don’t worry; SageMaker will handle the conversion during model training.
  4. Create an instance of the SageMaker K-means class and train your model. You can specify the number of epochs for training.
  5. Deploy your trained model as an endpoint for real-time inference.

Evaluating Model Performance

After deploying the model, you can evaluate its performance. Try submitting images to the model for predictions. Observe how well it groups similar images based on the K-means clustering.

Cleaning Up Resources

Remember to clean up resources to avoid incurring additional charges:

  1. Stop the Jupyter notebook kernel to halt the notebook instance.
  2. Stop and delete any training jobs, models, and endpoint configurations related to this tutorial.
  3. Delete the S3 bucket you created for this exercise.
  4. Remove any associated IAM roles and log groups.

By following these steps, you ensure that you only pay for the AWS resources you use during the tutorial.


Amazon SageMaker simplifies the entire machine learning lifecycle, from data preparation to model deployment. It empowers data scientists and developers to create and deploy machine learning models efficiently. This hands-on tutorial provides a practical introduction to SageMaker, and you can explore further by deploying your custom models in future tutorials.

Remember to explore the code and resources provided in the GitHub link below this video for a more detailed understanding of each step. If you have questions or topics you’d like to see in future tutorials, please share them in the comments. Happy learning and experimenting with Amazon SageMaker!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top