Skip to content

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)
diagram Diagram mermaid

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)
diagram Diagram mermaid

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
diagram Diagram mermaid

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

TypeLabels?OutputTypical use
SupervisedYespredictionspam, price, diagnosis
UnsupervisedNoclusters/structuresegmentation, anomalies
Semi-supervisedFewpredictionphoto tagging, few labeled examples
ReinforcementReward feedbackpolicycontrol, games

Batch vs online learning

A second way to classify ML systems: can they learn incrementally?

diagram Diagram mermaid
  • 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.

sketch Instance-based vs model-based prediction p5.js
The pink marker sweeps back and forth as the query point. The gold line is the model-based prediction, always calm and linear. The highlighted neighbors and dashed lines show the instance-based (k-NN) prediction jumping around as different neighbors come into range. Click to reshuffle the data.

Mini-checkpoint

Pick a real problem and decide:

  • supervised / unsupervised / semi-supervised / RL
  • batch or online
  • instance-based or model-based
  • what your XX and yy would 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 coffee

Was this page helpful?

Let us know how we did