Types of Machine Learning (Supervised, Unsupervised, Reinforcement)
1) Supervised learning
You have inputs X and the correct outputs y.
Goal: learn a function f(X) ≈ yf(X) ≈ y.
Examples:
- Regression: predict a number (house price)
- Classification: predict a category (spam vs not spam)
flowchart LR X["Features (X)"] --> M[Model] --> Y["Prediction (y_hat)"] YT["True Label (y)"] -. used for training .-> M
Common algorithms:
- linear/logistic regression
- KNN
- SVM
- decision trees, random forests
- gradient boosting
2) Unsupervised learning
You have inputs X but no labels.
Goal: discover structure.
Examples:
- clustering customers into groups
- anomaly detection
- dimensionality reduction (PCA)
flowchart LR X["Data (X)"] --> A[Unsupervised Algorithm] --> S[Structure / Groups]
Common algorithms:
- Clustering: k-means, DBSCAN, hierarchical clustering
- Anomaly / novelty detection: One-class SVM, Isolation Forest
- Visualization & dimensionality reduction: PCA, t-SNE
- Association rule learning: Apriori, Eclat (e.g. “people who buy BBQ sauce and chips also buy steak”)
3) Reinforcement learning
You have an agent acting in an environment.
The agent learns by trial and error to maximize reward.
Examples:
- robotics
- game-playing agents
- dynamic resource allocation
flowchart LR Agent -->|action| Env[Environment] Env -->|state, reward| Agent
Key terms:
- state: what the agent observes
- action: what the agent does
- reward: feedback signal
- policy: strategy mapping states → actions
4) Semi-supervised learning
Labeling data is slow and costly, so you’ll often have a lot of unlabeled instances and only a few labeled ones. Semi-supervised learning algorithms handle exactly this mix. Google Photos is the classic example: it first clusters faces that appear across your photos (unsupervised), and then you only need to add one label per person for it to name everyone everywhere. Most semi-supervised algorithms are really combinations of an unsupervised step followed by a supervised one.
Quick comparison table
| Type | Labels? | Output | Typical use |
|---|---|---|---|
| Supervised | Yes | prediction | spam, price, diagnosis |
| Unsupervised | No | clusters/structure | segmentation, anomalies |
| Semi-supervised | Few | prediction | photo tagging, few labeled examples |
| Reinforcement | Reward feedback | policy | control, games |
Batch vs online learning
A second way to classify ML systems: can they learn incrementally?
flowchart TD
subgraph Batch["Batch (offline) learning"]
B1["Train on ALL data"] --> B2["Deploy"] --> B3["Stops learning"]
B3 -.->|new data arrives| B4["Retrain from scratch"] --> B2
end
subgraph Online["Online learning"]
O1["Train on a mini-batch"] --> O2["Deploy & keep learning"]
O2 -->|new data arrives| O1
end
- Batch learning trains on the full dataset at once, offline. To learn about new data, you retrain a new model from scratch on old + new data and swap it in. Simple, but slow and resource-heavy for huge or fast-changing data.
- Online learning feeds the model data instances (or small mini-batches) sequentially. Each step is fast and cheap, so it’s great for streams like stock prices, and for out-of-core learning — training on datasets too big to fit in memory. The key tuning knob is the learning rate: high means it adapts fast but forgets old patterns quickly; low means more stability but slower adaptation.
Instance-based vs model-based learning
A third axis: how does the system generalize to new examples?
- Instance-based learning learns examples “by heart” and generalizes using a similarity measure — e.g. a spam filter that flags an email because it shares many words with known spam. k-Nearest Neighbors is the textbook example.
- Model-based learning builds a model (like a line, or a set of weights) from the training data, then uses that model — not the raw examples — to predict. Linear Regression is the textbook example.
The book’s running example: predicting life satisfaction from GDP per capita. A model-based approach fits a straight line and reads off the prediction. An instance-based approach (k-Nearest Neighbors) finds the k most similar countries by GDP and averages their satisfaction scores. Both can give similar answers — they just generalize differently.
Mini-checkpoint
Pick a real problem and decide:
- supervised / unsupervised / semi-supervised / RL
- batch or online
- instance-based or model-based
- what your
XXandyywould be
🧪 Try It Yourself
Exercise 1 – Unsupervised: Cluster Without Labels
Exercise 2 – Instance-Based: k-Nearest Neighbors
Exercise 3 – Online Learning: Learn Incrementally
If this helped you, consider buying me a coffee ☕
Buy me a coffeeWas this page helpful?
Let us know how we did
