What is Clustering, Inference in artificial intelligence, and how Machines learn ? - Free Learning series for AWS AI Certified Practitioner & Machine learning Engineer - Day 2

Logeshwaran.C

These two words get taught together and they are not the same kind of thing, which is why they confuse people. Clustering is a way of learning — you hand the machine data with no answers attached and it works out which items resemble each other, inventing the groups as it goes. Inference is a stage in a model's life — everything that happens after learning has stopped, when the finished model is answering questions. One is a method; the other is a phase. Use that distinction and most of the rest of the vocabulary falls into place. Confuse them, and deployment and billing will confuse you later.

⚡ Quick Answer

Clustering → grouping data with no right answers supplied. The machine invents the groups. More.

Inference → using a finished model to answer one question. Learning is already over. More.

Clustering vs classification → discovers the groups, versus sorts into groups you defined.

The one that costs money → inference, every time, because it runs on every request forever.

New here? Day 1 covers the five nested terms this post assumes.

The customer groups nobody could check

A sales rep had been in to see Jake with a marketing package. Feed it two years of shop sales, it finds your customer segments automatically, tells you who to target. Ninety dollars a month.

"It showed me a demo," Jake said. "Five groups, nice colors. But I couldn't work out how I'd know if the groups were right."

"You can't," Ethan said. "There's no right answer to check against. That's not the product being vague, that's what clustering is."

"Then how does anyone know if it works?"

"A human looks at the groups and decides whether they mean anything. Which is a completely legitimate way to work, as long as nobody pretends otherwise. Ask the rep one question: how many groups does it make, and who chose that number?"

The rep, to his credit, admitted the number was a setting. Five was the default.

That conversation is most of what is worth understanding about clustering, and it is the part left out of every explanation that stops at "it groups similar things together".

First, untangle the two words

They appear in the same lesson, so people file them as two related terms. They are not comparable at all, and that is the useful thing to notice.

  Clustering Inference
What kind of thing is it? A method of learning A phase of a model's life
When does it happen? During training After training, forever
Is the model changing? Yes — that is the point No. It is fixed
How often? Occasionally On every single request
Opposite of… Classification, roughly Training

The word inference is genuinely badly chosen for beginners. In ordinary English, to infer is to reason your way to a conclusion — which sounds exactly like learning. Here it means the opposite: the learning is finished, the model is frozen, and it is simply producing outputs.

If you remember one sentence from Day 2: during inference, nothing is being learned.

Clustering: the machine invents the groups

Day 1 covered the three ways a machine can learn. Clustering is the headline example of the second one, unsupervised learning, where the data arrives with no answers attached.

What it is actually doing

Underneath the various algorithms, the idea is simple: describe each item as a set of numbers, then put items that are numerically close to each other into the same group.

For Jake's customers, the numbers might be how often they visit, how much they spend per visit, how long since the last visit, and how many different kinds of thing they buy. Each customer becomes four numbers. Customers whose four numbers sit near each other end up together.

That is the whole trick, and it is why the choice of numbers matters more than the choice of algorithm. Describe your customers by postcode and shoe size and you will get groups — they will just be groups about postcodes and shoe sizes. The machine has no idea what any of the numbers mean. It only knows which are close.

You choose how many groups, and that changes the answer

This is the part the sales demo did not lead with, and it is the honest heart of the subject.

With many of the common algorithms, the number of groups is something you supply. Ask for three and you get three. Ask for eight and you get eight — from exactly the same data, with no error and no warning. Neither result is wrong.

There are ways to suggest a sensible number, and some algorithms work it out themselves from the shape of the data. But the underlying point survives all of them: a large part of what you get out was an assumption you brought in. When somebody shows you five customer segments, the correct first question is who chose five.

There is no accuracy score, and that is not a flaw

Anyone arriving from supervised learning expects a percentage. Ninety-four percent accurate. There isn't one, and there cannot be one, because accuracy is a comparison against known right answers and here there are none — if you had them, you would not be clustering.

What you get instead is two things.

Validity measures, which describe the shape of the result rather than its correctness: how tightly packed each group is, and how well separated the groups are from each other. Tight and well separated is generally better than loose and overlapping.

Human judgment, which is not a fallback but part of the method. Somebody who knows the business looks at the groups and asks whether they describe anything real, and whether you could act differently for one group than another. A mathematically excellent clustering that produces five groups you would treat identically has told you nothing.

That combination is a perfectly respectable way to work. It only becomes a problem when a product implies a certainty the method cannot provide.

Clustering versus classification, since everyone mixes them up

  Classification Clustering
The groups Already exist. You defined them Discovered. Nobody defined them
The training data Labelled by a human No labels at all
Can you score it? Yes — accuracy Not the same way
Jake's version "Is this invoice fake?" "Which customers are alike?"
Expensive part Getting the labels Interpreting the output

The last row is worth sitting with. Both approaches cost human effort; they just charge you at different moments. Supervised learning wants people before the model exists, marking up examples. Unsupervised learning wants people after, working out what the output means. Neither is the one that removes humans from the loop.

If classification is the side you need, supervised learning in depth — classification and regression covers it at engineer level.

Where clustering genuinely earns its place

  • Customer segmentation — the classic, and the one Jake was being sold. Useful when the groups lead to different actions.
  • Anomaly detection — a clever inversion. Cluster normal behavior, then treat whatever fits no group as suspicious. Widely used for fraud and for spotting equipment about to fail.
  • Organising piles of documents or images nobody has time to categorise by hand.
  • Exploring unfamiliar data before you know what questions to ask. Often clustering's most honest use: not an answer, a map.

The common thread: every one starts with unlabelled data, which is most data, because labelling is slow, expensive human work. That is the real reason unsupervised methods matter.

Inference: everything after the learning stops

Day 1 introduced the split — training builds the model, inference runs it. Here is why it earns a section of its own: almost every practical decision about cost, speed and architecture lives on the inference side.

The model is frozen while it answers

During inference the model does not change. It cannot learn from the question you just asked. Ask it the same thing a thousand times and you get the same answer a thousand times, give or take deliberate randomness in generative models.

So when a product "gets better the more you use it", something outside the model is quietly collecting your interactions, retraining on them later, and deploying a new version. That is a separate, deliberate, expensive process — and it is worth knowing, because it is also the sentence that should make you check what a product does with your data.

The bill nobody models

Training is a large cost you plan for: a known amount of compute, once, with a finance conversation attached.

Inference is a small cost with no natural limit. Each request is cheap. The number of requests is whatever your application decides to make — and applications retry, poll, prefetch, and get called from loops nobody documented.

When cloud AI spending runs away, the cause is essentially never training. It is inference volume that nobody estimated before launch. If you take one practical thing from Day 2, take that, because it applies whether you build models or only buy them.

Real-time and batch, and why the choice is expensive

  Real-time Batch
Shape Always ready, answers instantly Starts, processes a pile, stops
Use it when A person is waiting Nobody is waiting
You pay for All the time it is up, busy or not Only while it runs
Example Fraud check during checkout Scoring last month's transactions overnight

The trap is running a real-time endpoint for work that nobody is waiting on. It sits there, ready, billing, mostly idle — and it feels like the safe default because it is the one everybody sets up first while testing.

This is exactly the sort of thing certification scenarios ask about, because it is exactly the sort of thing that goes wrong in practice: read the question for whether a human is waiting for the answer, and the choice usually falls out of that one detail.

Why "the model is slow" is usually not the model

When a prediction feels slow, the model's own computation is often the smallest part of the delay. Ahead of it: the network round trip, preparing the input, loading the model into memory if it was not already there, and formatting the result on the way back.

The classic symptom is a first request that takes several seconds and subsequent ones that are quick. That is the model being loaded from cold, not the model being slow — and it is a deployment decision, not a modelling one. Knowing which of the two you are looking at saves people from optimizing the wrong thing for a week.

How machines learn from feedback

The third of the three learning types, and the one that fits neither of the patterns above.

In reinforcement learning there is no answer key and no pile of unlabelled data to organise. There is a goal, and a score after each attempt. The system tries something, sees how well it went, and adjusts to do better. Repeat, at enormous scale.

It suits problems that are sequences of decisions where only the end result can be judged — playing a game, controlling a machine, routing something through a series of steps. It suits them badly when a mistake is expensive in the real world, because the method depends on making a great many mistakes cheaply.

A relative of this idea shows up in modern language models, where people are shown two possible responses and asked which is better, and those preferences are used to steer the model towards answers humans actually like. The shape is the same: learning from a judgment about outcomes rather than from a correct answer.

Worth noticing what that means. When a model seems to have opinions about what a good answer looks like, that is not something it worked out. It is a preference somebody trained into it, on purpose, using ratings from people.

🔬 How this was written, and what it deliberately leaves out

Written on 9 August 2026 as Day 2 of this series, and kept conceptual on purpose. Where cloud platforms appear it is the general shape only — an endpoint that stays up and bills while it waits, against a job that starts, processes and stops — because that shape is stable and true across providers.

What you will not find here are specific service limits, prices or feature claims. Those move, this post does not need them to teach the ideas, and quoting numbers we had not checked on the day would be the kind of detail that quietly goes wrong six months later. The exam figures and the September 2026 certification dates all live in Day 1 of this series, linked at the foot of this page, where they were verified against AWS's own pages on the day of writing.

How this comes up in the exams

Clustering is usually tested through fit rather than mechanics. A scenario describes a business problem and you decide which type of learning suits it. The signal to look for is whether the data has answers attached. No labels and a request to find structure means unsupervised. Known categories and marked-up examples means supervised.

Inference turns up far more often than its share of the syllabus suggests, because deployment, cost and latency all sit on top of it. The recurring shape is a scenario where you choose between something always ready and something that runs on a schedule, and the deciding detail is almost always whether a person is waiting.

A habit worth forming for both: read the scenario for which phase it is describing. Is this about building a model or running one? Half of these questions answer themselves once you know.

For the engineer-level route, the next things worth reading are data fundamentals, ingestion and transformation — because on real projects the data work is most of the work — and the SageMaker built-in algorithms guide, which is where clustering stops being a concept and becomes something you configure.

🙋‍♂️ Jake's Reality Check

"So do I buy the ninety-dollar-a-month thing or not?"

Ask it two questions first, and they are not technical. What are the groups based on? — if it is only what people spent, you already know that from your own till. And what would I do differently for group two than group four? If you cannot answer the second one, the segments are decoration, however good the clustering underneath is. There is nothing wrong with paying for a tool that does the plumbing and the interface, that is real work and worth money. What is not worth ninety dollars a month is five colored circles you look at once. For a shop your size, honestly, sorting your customers by how recently they came in and how often gets you most of the way for the cost of an afternoon — and you will understand the result, which is more than most people get from a segmentation product.

What Day 2 should leave you able to say

  • Why are clustering and inference not comparable things?
  • Why can't you give a clustering result an accuracy percentage?
  • Who decides how many clusters there are, and why does that matter commercially?
  • Is the model learning while it does inference?
  • Which costs more over a year on a busy application, and why?
  • When would you choose batch inference over a real-time endpoint?
  • What does reinforcement learning use instead of correct answers?

If one of those sticks, that is the section to reread. Two minutes, and it is worth more than starting the whole page again.

Questions people actually ask about this

What is clustering in artificial intelligence?

Clustering is the machine sorting your data into groups that nobody defined in advance. You supply the examples with no labels and no right answers, and it works out which items resemble each other and puts those together. It is the best known form of unsupervised learning. The groups it produces are suggestions about structure in your data rather than verified categories, which is why a human always has to look at them and decide what they mean.

What is inference in AI?

Inference is using a finished model to answer one question. It is everything that happens after learning has stopped. Training builds the model, occasionally and expensively; inference runs it, constantly and cheaply per request. If a photo app tells you a picture contains a dog, that single answer is one inference. The word trips people up because in ordinary English inferring sounds like a kind of reasoning or learning, and here it means the opposite.

What is the difference between clustering and classification?

Classification puts items into groups that already exist and that you defined, using examples where somebody marked the correct answer. Clustering discovers the groups itself, from data with no answers attached. Classification can be scored because there is a right answer to compare against. Clustering cannot be scored the same way, because there is nothing to compare against, which is the difference that matters most in practice.

How do you know if a clustering result is good?

Not with an accuracy percentage, because there is no correct answer to measure against. You use validity measures that describe how tight each group is and how well separated the groups are from each other, and then a human decides whether the result is meaningful. That second half is not a weakness in the method, it is the method. A clustering that scores well mathematically and describes nothing you recognize is not a useful result.

How does the machine decide how many clusters to make?

With many common algorithms, it does not. You tell it, and the number you choose changes the answer you get. Ask for three groups and it finds three, ask for eight and it finds eight, from exactly the same data. There are methods that suggest a sensible number and some algorithms that work it out themselves, but the underlying point stands. The choice is an assumption you brought, not something the data told you.

Why is inference more expensive than training over time?

Because training happens occasionally and inference happens on every single request, forever. Training is a large, known, planned cost. Inference is a small cost multiplied by how often your application asks a question, and applications ask far more often than anyone estimates. When cloud AI costs run away, the cause is almost never too much training. It is inference volume nobody modelled before launch.

What is the difference between real-time and batch inference?

Real-time inference means a model sitting ready and answering the instant a request arrives, which is what you need when a person is waiting. Batch inference means collecting a large pile of work and processing it all at once on a schedule. Real-time costs you while it waits, because it has to stay running to be ready. Batch costs only while it works. Choosing the wrong one is one of the most expensive ordinary mistakes in this area.

Is clustering supervised or unsupervised learning?

Unsupervised. Supervised means the training data comes with the right answers attached, which somebody had to provide. Unsupervised means it does not, and the machine has to find structure on its own. Clustering is the most common example of unsupervised learning and it is usually the one used to explain the whole category, because the idea of sorting things into groups without being told the groups is easy to picture.

What is clustering actually used for?

Grouping customers who behave alike, spotting unusual activity by noticing what does not fit any group, organising large collections of documents or images nobody has time to categorise, and exploring an unfamiliar dataset before deciding what questions to ask of it. The common thread is that all of them start with data nobody has labelled, which is most data, because labelling is expensive human work.

How do machines learn from feedback?

In reinforcement learning the system tries something, receives a score telling it how well that went, and adjusts to score better next time. There is no set of correct answers, only a signal about outcomes. A related idea appears in modern language models, where human ratings of which response is better are used to steer the model towards answers people prefer. Both share the shape of learning from consequences rather than from an answer key.

Does inference mean the model is still learning?

No, and this is the most common misunderstanding of the word. During inference the model is fixed. It produces answers and it does not change itself, no matter how many questions it is asked. If a system appears to improve with use, something outside the model is collecting the new data and retraining it separately, then deploying the updated version. Learning and answering are distinct phases with distinct costs.

Why does my model feel slow when the model itself is fast?

Because most of the delay usually lives around the model rather than inside it. Time goes on the network round trip, on loading the model into memory if it was not already running, on preparing the input and on formatting the output. A model that has to start up from cold before answering the first request is a common cause of a first-response delay that disappears afterwards, and it is a deployment issue rather than a model issue.

Do I need to understand the mathematics of clustering?

Not for a foundational certification, and not to make good decisions about it. What you need is the shape: items are compared for similarity, similar ones are grouped, you usually choose how many groups, and the result is a suggestion rather than a verdict. If you are heading for an engineer-level exam or building this yourself, then yes, the differences between algorithms and how they measure distance start to matter a great deal.

Are AI customer segmentation products just clustering?

Frequently, yes, with a good interface on top. That is not a criticism, because the interface and the data plumbing are real work. It is worth knowing so you can ask the right question, which is not how clever the algorithm is but what the groups are based on and whether they are actionable. A tool that produces five customer groups you cannot do anything different for has produced nothing of value.

Where do clustering and inference appear on the AWS AI exams?

Clustering appears in the fundamentals domain, as part of knowing which type of learning suits which problem, and that is usually how it is tested rather than by asking about algorithms. Inference appears throughout, because deployment choices, cost and latency all depend on it, and the real-time versus batch decision is exactly the kind of scenario question these exams like. Knowing which phase a scenario is describing answers a surprising number of them.

What Jake asked the rep

What the groups were based on, and what he would do differently for one group than another.

The answer to the first was spend and visit frequency. The answer to the second was a pause, and then some talk about campaigns. Jake said he would think about it, and has not called back.

"I didn't even need the technical bit in the end. I just needed to know there wasn't a right answer hiding in there that I was too thick to see."

"That's most of what understanding this stuff buys you. Not building anything — knowing which questions the method can actually answer, so you can tell when somebody's promising more than it does."

Which is a fair place to leave Day 2. Clustering finds structure and hands you a suggestion. Inference is the part that runs forever and quietly sets your bill. Neither is magic, both are useful, and knowing which is which puts you ahead of a surprising number of people selling it.

Revision note. Originally published 17 October 2024 as Day 2 of this free series, written quickly and in plain language for people who wanted to learn this without buying expensive courses — which is still exactly who it is for. Rewritten on 9 August 2026. The original explained both terms; what it did not have room to say is that they are not the same kind of thing at all, and that this is where most beginners quietly go wrong. So this version untangles them first. Added since: the honest limits of clustering — no accuracy score, and a number of groups that you choose rather than discover — along with the real-time versus batch decision and the reason inference, not training, is what surprises people on a cloud bill. If a section here did not land, tell us which one through the contact page. This series exists because the paid material assumes you already know things, and the only way we find out where we have done the same is when somebody says so.

Related