Ravindra BagaleCourses & study guides मराठी Track your progress

AWS Cloud

What Is Amazon SageMaker? Machine Learning on AWS Explained

SageMaker is the big ML workshop on AWS: notebooks to explore, training jobs to learn from data, endpoints to serve predictions. Powerful — and easy to leave a meter running. Read the cost box twice.

In this chapter

  • What SageMaker is for
  • Notebooks vs training vs endpoints
  • Built-in algorithms vs your container
  • SageMaker vs Bedrock
  • Cost and sandbox warnings

1. Everyday example

A bank wants to score loan risk from past rows. Data scientists need a notebook, a training run on bigger machines, then an API that returns a score in milliseconds.

Amazon SageMaker is a managed set of services to build, train and deploy machine learning models on AWS without you assembling raw GPU clusters by hand.

Typical pathS3 datatraining setNotebookexplore & codeTraining jobfits the modelModel artifactin S3Endpointreal-time predict
Batch transform exists when you do not need a 24×7 endpoint.

2. Main pieces

Imagine a college wants to estimate tomorrow’s canteen lunches using past order counts, class schedules and holidays. A model is the fitted rule that estimates the number. Training uses examples that include actual counts, so the training program can tune the model. Give it past dates to learn from and keep some separate dates for a fair test. If the true counts for two held-out days were 100 and 120 and estimates were 90 and 132, the two misses were 10 and 12 lunches. An average miss of 11 is a starting point for deciding whether the model is useful.

In SageMaker AI, a training job can read the data from S3, run the training program, and leave a model artifact in S3. An artifact is the saved file or bundle produced by the job. Inference means giving the trained model new inputs to make a prediction. The notebook is a place to write and test your code, the job runs the training, and inference uses the resulting artifact. Follow the artifact from one stage to the next so you know what to check when one is missing.

PieceDoesBill watch
SageMaker Studio / Notebook instancesInteractive Python/R explorationInstance runs until you stop/delete
Training jobFits model on chosen instance typePays while the job runs
EndpointHosted HTTPS model for live trafficPays while InService — easy to forget
Processing / Batch transformOffline feature jobs / bulk scoresPays for the job duration

3. SageMaker vs Bedrock

Use the lunch example to choose the serving plan. If a manager asks for one prediction in a browser and expects a response immediately, consider a real-time endpoint. An endpoint is the address an app calls to get that response. If the college needs tomorrow’s predictions for all its canteens in one nightly file, Batch Transform can read a batch and write the output without maintaining a persistent endpoint. For a separate job such as summarising feedback, start with a suitable managed foundation model through Bedrock and compare the result on sample text. Each choice depends on the input, the result and when people need it.

  • SageMaker: you (or your team) train/customize models on your data; classic ML + many DL workflows.
  • Bedrock: call ready foundation models via API (chat, embeddings) — no GPU training required for the base model.
  • Many apps use both: Bedrock for text generation, SageMaker for a custom fraud model.

Cost & sandbox

Never leave notebook instances or endpoints running overnight in a student account. Prefer Studio with auto-shutdown where available. Delete endpoints after demos. Training on large GPU instances can cost a lot in one afternoon — start with tiny sample data and small instance types.

4. Interview angles

Describe a failed forecast in terms of the stage. A training job with no model artifact needs its input path, permissions and job logs checked. A successful job followed by poor predictions needs a representative held-out test. A deployed endpoint with errors needs its request format and serving logs checked. Keep those stages separate in your interview answer so that you can name evidence for each. In the no-cost paper lab, you can do the same sequence using a few given predictions before you create any cloud resources.

Q. Three pillars?

Build (notebooks), train (jobs), deploy (endpoints).

Q. Where do artifacts live?

Usually S3 model.tar.gz style outputs.

Q. Why not EC2 DIY?

SageMaker handles images, metrics, scaling patterns.

Q. Real-time vs batch?

Endpoint vs batch transform.

Q. Bedrock instead?

When a managed foundation model API is enough.

Try at home

  1. Open SageMaker console in ap-south-1 and list instance prices — do not create yet.
  2. Write one sentence: your project needs SageMaker or Bedrock?

In short

  1. SageMaker = build, train, deploy ML on AWS.
  2. Endpoints and notebooks bill while running.
  3. Bedrock is the better fit for many generative API apps.
  4. Delete lab resources the same day.

Practise this chapter

Interview questions and answers

Which SageMaker AI deployment would you use for a website that needs one immediate forecast versus a nightly file?

For one request that needs a quick response, consider a real-time endpoint. For a set of input rows processed offline at night, use Batch Transform to produce a prediction file without maintaining the real-time endpoint. In both cases the trained artifact must be available to the inference job.

Check your understanding

Choose an answer, then compare your reasoning with the explanation.

0 of 3 answered correctly
1. Which sample should you keep outside training to check a prediction fairly?

Answer and explanation

A. The held-out test dates

Testing on unused examples helps estimate how the model works on new inputs. To calculate error, you need known actual outcomes for those test dates.

2. What is the job of the saved model artifact?

Answer and explanation

A. Preserve the result of training for later inference

The artifact contains the trained model or files needed to invoke it later. It is separate from both the inputs and generated predictions.

3. A job only needs overnight predictions for one file. Which option avoids a dedicated persistent endpoint?

Answer and explanation

C. Batch Transform

Batch Transform runs a batch inference job for data available up front.

Apply the concepts

  1. A sixth canteen needs a forecast file once at night for the next day. Explain which inference choice avoids maintaining a dedicated online endpoint and name the input and output artifacts.

    Check your result

    Choose Batch Transform for the offline batch, identify new input rows in S3 and the resulting prediction file, and keep the trained artifact separate from the prediction output.

From past canteen orders to a checked forecast

Before you start

  • Use paper or a spreadsheet. The numbers are fictional and no AWS resources are required.
  • You need the idea of an S3 object and a row with an input date and an actual order count.
  1. Write four dated rows. Day 1: 102 orders. Day 2: 110 orders. Day 3: 100 orders. Day 4: 120 orders. Mark the first two as training examples and the last two as held-out test examples.

    Expected result: No test result is used to fit the model. Days 3 and 4 are available to measure how the trained rule works on new input.

  2. Use the simple baseline of the mean of training counts. Calculate it from days 1 and 2. Put the formula and number on a separate page labelled model artifact.

    Expected result: The trained baseline predicts 106 orders. The artifact contains the rule or its saved result, not an already computed test score.

  3. Apply the baseline to each held-out day. Compare each prediction with its actual count and compute mean absolute error.

    Expected result: Errors are 6 and 14 orders. Mean absolute error is 10 orders. This is a measurement on these two rows, with a larger evaluation needed before trusting a real forecast.

  4. Draw an AWS path for the same exercise: S3 training data to SageMaker AI training job to a model artifact in S3. Add a branch for immediate single predictions and one for nightly files.

    Expected result: The training job writes an artifact, real-time inference can serve the single request, and Batch Transform can produce a file without keeping a real-time endpoint.

If the result differs

  • If your prediction is 108, check whether you accidentally averaged all four dates. Train only on the marked rows.
  • If the forecast and score got mixed together, separate the predicted count from the absolute error against a known actual count.

Finish and clean up

  • Keep the one-page flow and remove temporary local sheets you no longer need. No endpoint, instance, or other cloud resource was created.

Practice Tasks

Practice checks run in your browser. They check the answer for this exercise; they do not create resources or connect to your AWS account.

About this scenario

Tokyo Ramen House is a restaurant business in Tokyo. Yuki Tanaka looks after its IT and cloud work. They count money in JPY and run their AWS resources in the ap-northeast-1 Region. In the tasks below you do real jobs for them using what this lesson teaches. All names, account IDs, IP addresses and numbers are made up for practice.

0 / 10

Easy List SageMaker endpoints

Endpoints cost money every hour; list them to find forgotten ones.

List SageMaker endpoints.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Easy List Bedrock models

See which foundation models are offered in your Region.

List the foundation models available in Amazon Bedrock.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Easy How many addresses in a /16?

Picking a VPC size needs this count.

Tokyo Ramen House plans the VPC 10.27.0.0/16. How many IP addresses does it hold in total?

  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Easy Port for SSH

Security group rules need the right port.

Which TCP port must the security group open for SSH?

  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Easy Show where you are

Before you copy or delete anything, you must know which folder you are in.

Yuki Tanaka logged in to the Tokyo Ramen House server and is not sure which folder the terminal is in. Print the current folder path.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Allow one Bedrock model

Limit apps to the approved model so costs stay predictable.

Allow bedrock:InvokeModel on arn:aws:bedrock:ap-northeast-1::foundation-model/amazon.nova-lite-v1:0 only.

  1. Start with { "Version": "2012-10-17", "Statement": [ ... ] }.
  2. In each statement write Effect, Action and Resource.
  3. Give only what the task needs (least privilege).
  4. Use double quotes and commas correctly. Click Check answer.

Medium Detect labels in an image

Rekognition names objects in a photo, e.g. to tag product images.

Detect labels in s3://tokyoramen-media/shop/p1.jpg (Bucket=tokyoramen-media, Name=shop/p1.jpg), max 10 labels.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Medium Delete an unused endpoint

Deleting a test endpoint stops the hourly bill.

Delete endpoint tokyoramen-demand-forecast.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Hard Ask a model a question

Converse is one API shape for many models.

Call converse on model amazon.nova-lite-v1:0 with the messages in msgs.json.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Hard Call a model endpoint

Your app sends features to the endpoint and gets a prediction back.

Invoke endpoint tokyoramen-demand-forecast with body from input.csv, content type text/csv, saving the result to out.json.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Revision, comparison and interview cards

Revise this lesson in a few minutes. Save the cards on your phone or download them as PNG files. The QR code on each card opens this lesson.

Revision card: What is Amazon SageMaker?. Banks and apps need notebooks, training on bigger machines, then a fast score API — without hand-building GPU clusters. Amazon SageMaker is a managed toolkit to build, train and deploy machine learning models on AWS. Explore in Studio/notebooks → run a training job → deploy an endpoint or use batch transform. A training job writes model.tar.gz style artifacts to S3; an endpoint serves HTTPS predictions.
Revision card: What is Amazon SageMaker? · Download PNG · Open card page
Revision card: SageMaker bill traps. Notebooks and endpoints bill while InService — easy to forget overnight. Stop or delete notebook instances and endpoints after demos. Start with tiny data and small instance types. Before any lab: set a budget alert; prefer auto-shutdown; never leave ml.g* GPUs running “just in case”. Cost Explorer shows endpoint hours drop to zero after delete; no surprise morning bill.
Revision card: SageMaker bill traps · Download PNG · Open card page
Revision card: SageMaker vs Bedrock. Teams ask for “AI on AWS” without knowing if they train or just call a model. SageMaker: you train/customize on your labelled data. Bedrock: call managed foundation models via API without training the base model. Fraud score on your rows → SageMaker. Chat/summarise with Claude/Llama-class models → Bedrock. Many apps use both: Bedrock for text, SageMaker for a custom classifier.
Revision card: SageMaker vs Bedrock · Download PNG · Open card page
Comparison: Amazon SageMaker vs Amazon Bedrock. Amazon SageMaker: You build/train/deploy models on your data. Amazon Bedrock: Call managed foundation models via API.
Comparison: Amazon SageMaker vs Amazon Bedrock · Download PNG · Open card page
Comparison: SageMaker real-time endpoint vs SageMaker batch transform. SageMaker real-time endpoint: Bills while the endpoint stays InService. SageMaker batch transform: Pays for the transform job duration only.
Comparison: SageMaker real-time endpoint vs SageMaker batch transform · Download PNG · Open card page
Interview card: Three pillars of SageMaker?. Build (notebooks/Studio), train (training jobs), deploy (endpoints or batch). Interviewers expect this map before feature-name soup. Notebook explore → Training job → Endpoint InService (then delete after demo).
Interview card: Three pillars of SageMaker? · Download PNG · Open card page
Interview card: Real-time endpoint vs batch transform?. Endpoint = always-on HTTPS model for live traffic (bills while InService). Batch transform = score a dataset offline and stop paying when the job ends. Chatty API scores → endpoint; nightly score 1M rows → batch transform.
Interview card: Real-time endpoint vs batch transform? · Download PNG · Open card page

More cards: Ravi Sir's Cards.