Interview's MateData Science
Interview's Mate

Data Science

Python → ML → MLOps

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Data Science topics
Lesson 81/ 160
05. Classical Machine Learning

Supervised vs Unsupervised Learning

Choose labeled prediction vs unlabeled structure discovery and know hybrid cases.

BeginnerLabeled Data · Clustering3 quiz questions
Practice Generative AI Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

With labels, you teach the computer the right answers; without labels, you ask it to find groups or patterns on its own.

Think of it like…

Supervised learning is a student with an answer key who practises and gets graded; unsupervised learning is an explorer with a pile of unlabelled photos who sorts them into piles that seem to belong together and then asks whether the piles are useful.

Where you’ve seen it

A subscription company has 20,000 customers, 1,200 of whom churned (6%). Question 1, "who will churn next month?" is supervised classification with the churn flag as the target. A baseline that predicts "no churn" for everyone is 94% accurate and useless, so the team evaluates with precision, recall and PR-AUC instead; to learn from at least 500 positive examples they need 500 ÷ 0.06 = 8,333 labelled customers, which they already have from history. Question 2, "what kinds of customers do we have?" has no label: they run k-means on usage and spend features and obtain 5 segments with a silhouette score of 0.41, then check that the segments differ in ways marketing can act on. A hybrid follows: segment membership becomes a feature in the churn model, and a separate model is trained for the segment with the most churn. For a new product with no history, they use active learning, labelling the 1,000 most uncertain customers instead of 1,000 random ones.

Words you’ll hear

Target / label
The outcome a supervised model learns to predict.
Clustering
Grouping unlabelled rows by similarity.
Semi-supervised / self-supervised
Learning from few labels plus structure, or from labels created from the data itself.
Baseline
A trivial model (majority class, mean) that any real model must beat.

Visual diagram

Loading interactive diagram

Theory & deep dive

Supervised learning: targets, data needs and evaluation

A supervised problem needs features X, a target y and a definition of success. For classification the target is categorical (churn, fraud, spam) and typical metrics are precision, recall, F1, ROC-AUC and PR-AUC; for regression it is numeric and metrics are MAE, RMSE and R². Always compute a baseline (majority class, mean or last value) first: with 6% positives, predicting all negatives scores 94% accuracy, which is why accuracy alone misleads on imbalanced data. Label quality limits everything: noisy or delayed labels (a churn flag known only after 90 days) cap the achievable score and shape how you split data over time.

Estimate the label budget. To have about 500 positive examples of a rare class with prevalence p you need roughly 500 ÷ p labelled rows (8,333 at 6%); rare events (fraud at 0.2%) need 250,000. When labels are expensive, use active learning (label the examples the model is least sure about), weak supervision (heuristics or LLM-generated labels, validated on a hand-labelled sample) or transfer learning from a pretrained model. Remember that some targets are not available at prediction time: define the prediction moment first and use only information known then.

The accuracy trap

20,000 customers, 1,200 churners. Predicting "no churn" for all: accuracy = 18,800 / 20,000 = 94%, recall = 0%. A model with 70% recall and 30% precision at a chosen threshold is far more useful although its accuracy may be lower.

Key takeaway: Supervised learning needs a trustworthy target and baseline; evaluate with metrics that fit the class balance.

Unsupervised learning, hybrids and how to choose

Unsupervised methods answer exploratory questions: clustering (k-means, hierarchical, DBSCAN) finds groups; dimensionality reduction (PCA, t-SNE, UMAP) compresses or visualises; anomaly detection (isolation forest) flags rare points; association rules find co-occurrence. Without a ground truth, evaluate by internal measures (silhouette, within-cluster variance), stability (do clusters reappear on resampled data?), interpretability (can you name each segment?) and, above all, downstream value (do segments respond differently to an offer?). A clustering result that isn't actionable is a chart, not a finding.

In practice, paradigms combine: cluster membership or PCA components as features for a supervised model; anomaly scores as inputs to a fraud classifier; self-supervised pretraining (embeddings) followed by supervised fine-tuning with few labels. Choose by asking: (1) Is there a well-defined target available at decision time? (2) Do I have enough reliable labels, or can I get them affordably? (3) Is the goal prediction, grouping, compression or detection? (4) How will success be measured and who acts on the result? If the answers are unclear, start with exploration (unsupervised), define the target with stakeholders, then move to supervised modelling.

Segments as features

K-means gives 5 usage segments. Adding the segment id (one-hot) to the churn model lifts PR-AUC from 0.31 to 0.34, and the model for "high-spend, falling-usage" customers is tuned separately because its churn rate is 14% versus 4% elsewhere.

Key takeaway: Use unsupervised methods for structure and exploration, judge them by usefulness, and combine them with supervised models.

How it works, step by step

Step 1 of 4
Analyst

1. Define the decision

State what will be decided or acted on, at which moment and by whom.

predict churn 30 days ahead
Key numbers at this step
Prediction
moment defined

When to use it & trade-offs

What it is

Supervised learning learns a mapping from inputs to a known target (a label or number) using examples where the answer is given: classification (churn: yes or no) and regression (price in dollars). Unsupervised learning has no target; it finds structure in the inputs themselves: clustering (segments), dimensionality reduction (PCA), density estimation and anomaly detection. In between sit semi-supervised learning (a few labels plus many unlabelled rows), self-supervised learning (labels derived from the data, as in language models) and weak supervision (noisy rules as labels). The choice is driven by the business question and by whether you can obtain reliable labels at a reasonable cost.

Why it matters: Picking the wrong paradigm wastes months: clustering customers when the real question is "who will churn" gives segments nobody can act on, while hunting for labels to supervise a task that is really exploratory (what groups exist?) blocks progress. Evaluation also differs: supervised models have an objective score on held-out labels, whereas unsupervised results must be judged by stability, separation and, above all, usefulness for a decision.

When to reach for it

  • Framing a new modelling project
  • Deciding whether to invest in labelling
  • Combining segmentation with prediction

When to avoid or be careful

  • Clustering when a clear target exists
  • Evaluating with accuracy on rare classes
  • Treating clusters as ground truth

Learning paradigms

Supervised
Best for: Predicting a known outcome with labelled history

Strengths: Objective evaluation; direct business metric.

Watch out: Needs labels, which are costly or delayed.

Unsupervised
Best for: Exploration, segmentation, compression and anomalies

Strengths: No labels needed; reveals structure.

Watch out: Hard to evaluate; results may not be actionable.

Semi- or self-supervised
Best for: Few labels but many unlabelled rows

Strengths: Leverages unlabelled data; fewer labels.

Watch out: More complex pipelines; label noise issues.

Interview signals & numbers to know

When this topic comes up

  • “We have no labels”
  • “What groups do our customers fall into?”
  • Majority-class baseline
  • Active learning
  • Segment-based features

Benchmarks & rules of thumb

94% -
accuracy of predicting no churn at 6% prevalence
500 ÷ p -
rows needed for about 500 positive examples
8,333 -
labelled customers needed at p = 0.06

Common mistakes & follow-ups

Common interview mistakes

  • Defining the target with information that isn't known at prediction time.
  • Reporting high accuracy on an imbalanced problem without a baseline.
  • Presenting clusters without checking whether they are stable or actionable.

Likely interviewer follow-ups

  • When would you choose clustering over classification?
  • How would you work with very few labels?
  • How do you evaluate an unsupervised model?
Interview tip: Start with the decision and the baseline. Interviewers like to hear that the paradigm follows the question, not the other way round.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply Supervised vs Unsupervised Learning with data science interview Q&A and hands-on practice.

Open Data Science Q&A →Machine Learning Q&A
Previous topic
Stakeholder Presentation & Decision Framing
Next topic
Train-Validation-Test Splits & Data Leakage