Supervised vs Unsupervised Learning Explained

Supervised and unsupervised learning represent two fundamentally different approaches to training a model — the presence or absence of labeled “correct answers” during training is the core distinction, with real implications for what each is good for.

# Supervised learning: trained on INPUT-OUTPUT pairs with known correct answers
from sklearn.linear_model import LogisticRegression

X_train = [[25, 50000], [45, 90000], [30, 60000]]  # age, income
y_train = ['no_purchase', 'purchase', 'no_purchase']  # KNOWN correct labels

model = LogisticRegression()
model.fit(X_train, y_train)   # learns to map inputs to KNOWN correct outputs

# Unsupervised learning: NO labels - finds structure/patterns on its own
from sklearn.cluster import KMeans

X_customers = [[25, 50000], [45, 90000], [30, 60000], [50, 95000]]
clustering = KMeans(n_clusters=2)
clustering.fit(X_customers)   # groups similar customers together,
                                # with NO predefined "correct" grouping given

What Each Is Actually Good For

  • Supervised — classification (spam/not spam), regression (predicting a price), anything with a clear, known target to predict
  • Unsupervised — clustering (customer segmentation), anomaly detection, dimensionality reduction — finding structure when you don’t know in advance what you’re looking for

Where LLMs Actually Fit

Modern LLMs are pretrained in a largely self-supervised way (predicting the next word in vast amounts of unlabeled text — technically neither purely supervised nor purely unsupervised in the classic sense), then fine-tuned using genuinely supervised and reinforcement learning techniques (RLHF) — a hybrid approach that doesn’t map cleanly onto either classic category alone.