Back to Machine Learning
Machine Learning

What are the main differences between supervised, unsupervised, and reinforcement learning paradigms?

Supervised uses labeled data, unsupervised finds patterns without labels, and RL learns policies via reward feedback.

G
Gaurav Bhasin 👑 Tier 3 Elite
Aug 9, 2026 · 2 min read

Supervised learning maps inputs to known targets, unsupervised discovers structure without labels, and reinforcement learning optimizes actions through trial‑and‑error rewards.

1. Supervised learning
• Goal: predict y from x.
• Loss: cross‑entropy, MSE, etc.
• Typical APIs: torch.nn.CrossEntropyLoss(), sklearn.metrics.accuracy_score.
• Example: image classification with ResNet‑50 on ImageNet (top‑1 ≈ 85%).

2. Unsupervised learning
• Goal: model p(x) or extract latent representation.
• Losses: reconstruction (MSE), contrastive InfoNCE, KL‑divergence.
• Common tools: sklearn.decomposition.PCA, torch.nn.TransformerEncoder for self‑supervised, torch_cluster for graph clustering.
• Example: k‑means (k=10) on MNIST embeddings yields ~85% cluster purity.

3. Reinforcement learning
• Goal: learn policy π(a|s) that maximizes cumulative reward R = Σγ^t r_t.
• Algorithms: PPO, SAC, DQN.
• Libraries: stable-baselines3 (e.g., PPO('MlpPolicy', env)).
• Example: training an agent in gymnasium CartPole reaches 200 reward in < 500k steps.

| Paradigm | Labels required | Typical loss | Common lib/API |
|----------|----------------|--------------|----------------|
| Supervised | Yes | Cross‑entropy, MSE | torch.nn, sklearn |
| Unsupervised | No | Reconstruction, contrastive | sklearn, torch.nn |
| RL | Reward signal only | Policy gradient, TD error | stable‑baselines3, gymnasium |

Decision checklist
- Do you have ground‑truth y? → Supervised.
- Need to explore data structure or reduce dimensionality? → Unsupervised.
- Problem involves sequential decision making with delayed reward? → RL.

# Supervised: PyTorch training loop
import torch, torch.nn as nn, torch.optim as optim, torchvision
model = torchvision.models.resnet50(pretrained=False, num_classes=1000)
criterion = nn.CrossEntropyLoss()
optimizer = optim.AdamW(model.parameters(), lr=3e-4, weight_decay=0.01)
for xb, yb in train_loader:
    logits = model(xb)
    loss = criterion(logits, yb)
    optimizer.zero_grad()
    loss.backward()
    optimizer.step()
# Unsupervised: k‑means on embeddings
from sklearn.cluster import KMeans
emb = torch.nn.functional.normalize(model(x).cpu().numpy())
kmeans = KMeans(n_clusters=10, random_state=42).fit(emb)
labels = kmeans.labels_
# RL: PPO with stable-baselines3
from stable_baselines3 import PPO
import gymnasium as gym
env = gym.make("CartPole-v1")
model = PPO('MlpPolicy', env, learning_rate=2.5e-4, gamma=0.99, verbose=0)
model.learn(total_timesteps=200_000)

Read the evidence

Sources used in this thread

Open the original material, compare the claims, and form your own view.

Community notes

Add context, not noise (0)

Corrections, lived experience, useful examples, and better sources belong here.

Nothing added yet. Be the first to make this thread more useful.
Click here to write a reply...
🔒

Authentication Required

Join Trendzza to begin your journey. Submit tasks, complete batches, help peers, and earn your way to Tier 3.