Unsupervised Learning: lesson 1 of 4
Unsupervised Learning
What Is Unsupervised Learning?
Learn how unlabeled data can reveal useful structure without a target to predict.
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
| Question | Supervised learning | Unsupervised learning |
|---|---|---|
Is a target y known? | Yes | No explicit target |
| Main goal | Predict an outcome | Discover structure or a representation |
| Example | Predict churn | Explore customer groups |
| Typical result | Price, class, or probability | Cluster 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
- Treating every analysis without a target as unsupervised machine learning. A descriptive report may be all that is needed.
- Calling an algorithmic cluster a verified customer type without reviewing the underlying rows.
- Ignoring feature scale, missing values, and outliers before distance-based methods.
- Assuming an interesting pattern explains why something happened. Structure is not causal evidence.
- 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
- A company has transaction behavior but no segment labels. What kind of learning setup is appropriate, and what should it produce?
- Why might two reasonable preprocessing choices create different customer clusters?
- A model returns three clusters. What additional evidence would you seek before using them in a marketing campaign?
- Is finding unusually different transactions always a supervised task? Explain your reasoning.
- A manager wants total revenue by region. Why might an ordinary grouped report be more appropriate than unsupervised learning?
Quick Quiz
- Does unsupervised learning use a target vector
y? Answer: Not as the outcome it is asked to predict. - What do cluster labels
0,1, and2mean by themselves? Answer: Only arbitrary identifiers. - 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.