Skip to content
GenAI Learn/How Machines Learn
Browsing as a guest. Sign in to save your progress and earn XP as you complete chapters.

Unsupervised Learning: Finding Structure

5 min read

You'll learn to

  • -Define unsupervised learning and how it differs from supervised learning
  • -Recognize clustering and dimensionality reduction as the two main unsupervised tasks
  • -Run a tiny k-means by hand and see centers move to the middle of their groups
  • -Say how you would judge a result when there are no labels to check against

Tip: the highlighter is on - just select any text below to mark it. Use the highlighter button up top to change color or turn it off. Highlights are saved on this device only. Log in to save them to your account instead.

Unsupervised learning removes the labels entirely. You give the algorithm a pile of unlabeled data and ask it to find structure, groupings, patterns, or a simpler representation, without ever telling it what the "correct" answer looks like.

An Analogy: A Pile of Unlabeled Photographs

Someone hands you a box of loose photographs with no captions and asks you to organize them. Nobody tells you the categories. You look, and you start putting similar pictures together: beaches here, birthdays there, a pile of portraits. You have made groups without ever being told what the right answer was. That is clustering. Then you decide to summarize the box on a single index card, keeping only the few things that distinguish one photo from another. That is dimensionality reduction.

Clustering: Finding Natural Groups

Clustering algorithms group similar examples together. A retailer might cluster customers by purchasing behavior without predefining what the groups should be. The algorithm might discover a cluster of weekend bulk buyers and a cluster of frequent small purchasers on its own, patterns a human analyst might never have thought to look for.

A Tiny K-Means, Run by Hand

K-means is the classic clustering method. Say six customers spend 5, 6, 7, 50, 52 and 55 a month, and you ask for two groups. Start with two rough centers, 5 and 55. Then repeat two steps: assign every customer to the nearest center, and move each center to the mean of its group.

K-means with two groups: assign to the nearest center, move the centers, repeat

The first pass puts 5, 6 and 7 in one group and 50, 52 and 55 in the other. The centers move to 6.0 and 52.3, the means of their groups, and the next passes change nothing, so the algorithm has settled. Nobody told it that there were light spenders and heavy spenders; the groups came out of the data.

Dimensionality Reduction: Finding a Simpler Representation

Real-world data often has far more measured attributes than actually matter. Dimensionality reduction compresses data into fewer, more informative dimensions while preserving as much of the meaningful structure as possible, useful for visualization, for speeding up other algorithms, and for filtering out noise.

A picture helps for the second task. A photograph is a flat shadow of a three-dimensional scene, and it keeps most of what matters. Dimensionality reduction does that with data: it picks the angle from which the points are most spread out, so the few dimensions you keep preserve as much of the structure as they can. The classic method is PCA.

A simple way to remember the distinction: supervised learning answers a question you already knew how to ask, like "is this spam?" Unsupervised learning answers a question you did not know to ask, like "what natural groups exist in this data?"

How Do You Know the Result Is Any Good?

With no labels there is no accuracy to compute, but you are not helpless:

  • -Do the groups differ in ways you can describe and act on? A cluster of weekend bulk buyers is useful. A cluster with no obvious character probably is not.
  • -Is the result stable? Run it again with a different start or on a different sample. If the groups change every time, they were not really there.
  • -Use an internal score. The silhouette score runs from -1 to 1 and asks, for every point, whether it is closer to its own group than to the next nearest one.
  • -Check it against a later outcome. If clusters of users behave differently afterwards, for example in how often they churn, the clusters carry real information.
  • -Because there are no labels to check against, evaluating unsupervised learning is inherently fuzzier than evaluating supervised learning.
  • -Unsupervised methods are often used as a first exploratory pass over data before deciding what supervised problem is even worth solving.
Interview Signal

Your team has a large database of user behavior with no predefined categories, and a stakeholder wants to know what types of users you have. How would you approach this, and how would you know if the result is any good?

Weak Answer

"I would build a classifier to sort users into a few obvious categories I already have in mind."

Strong Answer

"Since there is no predefined label for user type, this is an unsupervised clustering problem rather than a classification problem. I would run clustering over the behavioral features and let the algorithm discover groupings rather than imposing categories in advance. Evaluating the result is harder than in supervised learning, since there is no ground truth to check against, so I would look at whether the clusters are stable, interpretable to a domain expert, and actually useful for the business decision at hand, rather than relying on a single accuracy number."

Check Yourself1 / 5

What is the fundamental difference between unsupervised learning and supervised learning?

Discussion0

Join the Discussion

Sign in to leave comments, reply to others, or like insights.

Sign In to ScaleDojo

No comments yet. Be the first to start the thread!