Lesson 2 of 18 · 2 min
Types of Machine Learning
Three main types based on how the model learns:
1. Supervised Learning
Model learns from labelled data — each input has a known correct output.
- Training data has both X (features) and y (correct answer)
- Model learns to map X → y
- Used for: Regression and Classification
Examples:
- Predict house price (y = price, X = area/bedrooms/location)
- Email spam detection (y = spam/not spam, X = email content)
- Cancer diagnosis (y = malignant/benign, X = scan features)
# Supervised: we provide both X and y model.fit(X_train, y_train) # model learns from labelled examples model.predict(X_test) # predicts y for new X
2. Unsupervised Learning
Model learns from unlabelled data — no correct answers given. Finds hidden patterns on its own.
- Training data has only X (no y)
- Model discovers structure, groups, or patterns
- Used for: Clustering, Dimensionality Reduction
Examples:
- Customer segmentation (group customers by buying behaviour — no predefined groups)
- Anomaly detection (find unusual transactions without labelled fraud data)
- Topic modelling (discover themes in news articles)
# Unsupervised: only X, no y from sklearn.cluster import KMeans model = KMeans(n_clusters=3) model.fit(X) # finds 3 natural groups in data — no labels needed
3. Reinforcement Learning
Agent learns by trial and error — takes actions, receives rewards or penalties, improves over time.
- No dataset — agent interacts with an environment
- Goal: maximise cumulative reward
- Used for: Games, robotics, self-driving cars
Examples:
- AlphaGo (learned to play Go by playing millions of games against itself)
- Self-driving cars (reward for safe driving, penalty for collisions)
- Trading bots (reward for profitable trades)
Quick Comparison
| Supervised | Unsupervised | Reinforcement | |
|---|---|---|---|
| Has labels (y)? | Yes | No | No |
| Goal | Predict y for new X | Find patterns/groups | Maximise reward |
| Examples | Regression, Classification | Clustering, PCA | Games, Robots |
| Data needed | Labelled dataset | Unlabelled dataset | Environment to interact with |
This course covers Supervised Learning — Regression and Classification.
