Unsupervised Learning: lesson 1 of 4

Unsupervised Learning

PATH 02MODULE 08LESSON 01 OF 04Next: Clustering with K-Means and Choosing K

What Is Unsupervised Learning?

Learn how unlabeled data can reveal useful structure without a target to predict.

Beginner14 min readmachine-learningunsupervised-learningclusteringdimensionality-reduction

Concept

Unsupervised learning works with data that has input features but no known answer column. Instead of learning X -> y, an algorithm looks for useful structure in X: groups of similar observations, unusually different observations, or a simpler representation of many variables.

That changes the question. A supervised churn model asks, "Which customers will churn?" because historical churn labels are available. An unsupervised segmentation exercise asks, "What patterns of customer behavior appear in the data?" There may be no pre-existing segment label to learn.

Why It Matters

Real datasets are often rich in behavior but poor in labels. A retailer may know each customer's annual spend, purchase frequency, account age, and average order value without agreeing on customer segments. Unsupervised methods can make that table easier to explore and discuss.

They are also useful before a predictive project. A cluster profile may reveal that a supposed single customer population actually contains several very different groups. That can guide later feature engineering, data collection, or business investigation. It does not, by itself, prove that the groups are real business categories.

Supervised vs Unsupervised Thinking

QuestionSupervised learningUnsupervised learning
Is a target y known?YesNo explicit target
Main goalPredict an outcomeDiscover structure or a representation
ExamplePredict churnExplore customer groups
Typical resultPrice, class, or probabilityCluster labels or components

The absence of y is the important distinction. A table can still have many columns, but none is the answer the algorithm is asked to predict. The result is therefore exploratory: it suggests patterns worth interpreting rather than confirming a known outcome.

Two Main Tasks in This Module

Clustering groups observations that look similar under a chosen representation. For a customer table, groups might differ in spend, frequency, and account age. K-Means and hierarchical clustering are two ways to explore such groups.

Dimensionality reduction summarizes a dataset with fewer variables. A table with 50 correlated sensor readings is difficult to visualize and reason about. Principal Component Analysis (PCA) creates a smaller number of new components that preserve useful variation, with some loss of direct interpretability.

Other unsupervised methods exist, including anomaly detection and density-based clustering. This module focuses on the two tasks above because they establish the core reasoning: patterns depend on data representation, choices, and interpretation.

Real-World Example: Customer Segmentation

Suppose a subscription business has these fields for each customer:

features = [
    "annual_spend",
    "purchase_frequency",
    "account_age_months",
    "average_order_value",
]

X = customers[features]

A clustering method may place customers with high frequency and high annual spend in one group, and infrequent low-spend customers in another. The output labels might be 0, 1, and 2. Those numbers are identifiers chosen by the algorithm, not meanings. Calling group 2 "loyal high-value customers" is a human interpretation made only after checking its profile, sample records, and usefulness for a decision.

Similarity Is a Modeling Choice

Most introductory clustering methods compare observations using distance. That means the definition of similarity depends on selected features and their scales. If age ranges from 20 to 60 while annual income ranges from 20,000 to 200,000, income can dominate a distance calculation simply because its numbers are larger.

This is why preprocessing matters. Scaling numeric features can put comparable variables on a common scale before distance-based clustering. It is not a cosmetic step: scaling, missing-value treatment, outliers, and feature choice can materially change the groups an algorithm returns. Use the Data Preprocessing principles from earlier modules, and make each choice explicit.

Evaluation Is Different Without Labels

With a known target, a held-out test set can compare predictions with actual outcomes. In unsupervised learning there may be no accepted correct grouping. We therefore combine several forms of evidence:

  • internal structure measures, such as cluster compactness;
  • stability when reasonable data or setup changes are made;
  • visual inspection where it is appropriate;
  • domain review of group profiles; and
  • whether the result supports a useful downstream decision.

None of these turns clusters into objective truth. A mathematically neat grouping can still be irrelevant to marketing, operations, or product work.

Failure Signals

Common Mistakes

  1. Treating every analysis without a target as unsupervised machine learning. A descriptive report may be all that is needed.
  2. Calling an algorithmic cluster a verified customer type without reviewing the underlying rows.
  3. Ignoring feature scale, missing values, and outliers before distance-based methods.
  4. Assuming an interesting pattern explains why something happened. Structure is not causal evidence.
  5. Using clusters as decisions before checking whether they are stable and useful.

Best Practices

Start with a decision or exploration question, even when there is no label. Document the row grain, features included, preprocessing choices, and what similarity should mean in the domain. Profile the resulting groups with summaries and examples. Treat names such as "high value" as hypotheses to validate, not facts supplied by the algorithm.

Interview Perspective

Question: How does unsupervised learning differ from supervised learning?
Answer: Supervised learning uses known targets to learn predictions; unsupervised learning has no explicit target and explores structure in the features.
What the interviewer is testing: whether you can reason from the available feedback rather than describe algorithms as magic.
Follow-up: Why is a cluster not automatically a real customer segment?

Practice Questions

  1. A company has transaction behavior but no segment labels. What kind of learning setup is appropriate, and what should it produce?
  2. Why might two reasonable preprocessing choices create different customer clusters?
  3. A model returns three clusters. What additional evidence would you seek before using them in a marketing campaign?
  4. Is finding unusually different transactions always a supervised task? Explain your reasoning.
  5. A manager wants total revenue by region. Why might an ordinary grouped report be more appropriate than unsupervised learning?

Quick Quiz

  1. Does unsupervised learning use a target vector y? Answer: Not as the outcome it is asked to predict.
  2. What do cluster labels 0, 1, and 2 mean by themselves? Answer: Only arbitrary identifiers.
  3. Why can scaling affect clustering? Answer: Distance-based similarity can be dominated by features with larger numeric ranges.

Key Takeaway

Key Takeaways

Unsupervised learning explores structure in unlabeled features. Clustering groups similar observations, while dimensionality reduction creates a compact representation. Both depend on data preparation and require domain interpretation.

Next Lesson

Next, see how K-Means repeatedly assigns observations to centroids and why choosing the number of clusters is a judgment, not an automatic answer.

Finish this lesson on your terms

Mark it complete when you have worked through the material and are ready to move on.