Explain what machine learning is, how it differs from hand-written rules, and name its three main types with an example of each.
Describe what makes learning supervised, its goal, its workflow, and how classification differs from regression.
Describe what unsupervised learning works with, what it's trying to find, its main task, and its benefits.
Describe how an agent learns, what a policy is, and walk through the reinforcement learning loop.
Explain what training is and walk through the five-step training loop, using a model that predicts 4.2 when the correct answer is 7.0.
Explain what prediction is, why it matters, and how it works without the correct answer.
Explain spam detection as an ML problem: its type, training data, what it learns, and the five-step flow.
Explain the data a recommender uses, the mix of techniques, and its five-step flow.
Explain why building a model isn't enough and what evaluation gives you.
Lay out the confusion matrix and define its four outcomes. Every other metric is built from this table.
Give the accuracy formula, what it measures, and why it can mislead.
Give the precision formula, the question it answers, and when it matters most.
Give the recall formula, the question it answers, and when it matters most.
Give the F1 formula, what it combines, and when it's the right metric.
Explain why cross-validation beats a single train/test split and walk through k-fold with k = 5.
Describe overfitting, how it performs on training vs. new data, its common causes, and what its curve looks like.
Describe underfitting, how it performs, its common causes, what it looks like, and four ways to fix it.
| Type | Learns from | Goal | Main task | Examples |
|---|---|---|---|---|
| Supervised | Labeled data — every example already has a known correct answer | Learn a mapping from inputs (features) to outputs (labels) | Classification (categories) and regression (numbers) | Spam vs. not spam; a house's price |
| Unsupervised | Data with no labels or correct answers | Discover hidden structure, groupings, or relationships | Clustering — grouping similar items together | Customer segmentation; grouping similar news articles |
| Reinforcement | Interacting with an environment — rewards or penalties for its actions | Learn a strategy (a policy) that maximizes long-term reward through trial and error | Not named as a single task in the lecture | Game-playing AI; robotics; self-driving car decision-making |
A labeled dataset — the last column is the known answer:
| Feature 1 | Feature 2 | … | Answer (label) |
|---|---|---|---|
| 2.1 | 3.4 | … | Yes |
| 1.5 | 2.1 | … | No |
| 3.2 | 1.8 | … | Yes |
| 2.7 | 3.1 | … | No |
| 1.8 | 2.9 | … | Yes |
Supervised learning's two tasks:
| Task | Predicts | Output | Example |
|---|---|---|---|
| Classification | Categories | Discrete — Yes/No, Spam/Not Spam, Cat/Dog | Is this email spam or not spam? |
| Regression | Numbers | Continuous — price, temperature, sales (e.g., 12.5, 98.7) | Predicting the price of a house |
X = the features, lowercase y = the target (the label column). Unsupervised data has no labels, so there's no y to learn.| Term | Meaning |
|---|---|
| Agent | The learner or decision maker that chooses actions |
| Environment | The world the agent interacts with; it responds to actions |
| Reward / penalty | Feedback signal for a good (reward, e.g., +10) or bad (penalty, e.g., −5) outcome |
| State | The current situation, sent from the environment back to the agent |
| Policy | The strategy the agent learns to maximize long-term reward |
The learning process:
| Step | What happens |
|---|---|
| 1. Data (input) | Many training examples are provided to the model. |
| 2. Model prediction | The model makes a prediction (its guess). |
| 3. Compare to correct answer | Check how wrong the prediction was (calculate error/loss). Example: prediction 4.2, actual 7.0 → error/loss = 2.8. |
| 4. Adjust model (learn) | The model updates its internal parameters to reduce future errors. |
| 5. Repeat | The updated model sees the data again and the cycle repeats. |
Over time: poor predictions / high error → improving / lower error → better / even lower error → best model / low error. Goal achieved: accurate predictions on new, unseen data.
Key benefits: learns automatically from data; improves with more practice; adapts to complex patterns.
| Training | Prediction | |
|---|---|---|
| Input | Many training examples | Brand-new, unseen input |
| Needs the correct answer? | Yes — compares its guess to it | No — instant prediction without it |
| Model changes? | Yes — adjusts internal parameters | Not described as changing |
| Result | A model that keeps getting better | A predicted label or value |
An inbox the model has sorted:
| From | Subject | Status |
|---|---|---|
| Alice Johnson | Meeting tomorrow | Not Spam |
| Bank Alert | Your account update | Not Spam |
| Win a FREE iPhone! | Claim your prize now!!! | Spam |
| Cheap Meds Online | Lowest prices guaranteed | Spam |
| Newsletter | Weekly update | Not Spam |
| Earn $$$ Fast | Work from home today | Spam |
The lecture covers the matrix after the metrics, but every metric is calculated directly from this table — so start here.
| Metric | Formula | Question it answers | High value means | Matters most when | Example |
|---|---|---|---|---|---|
| Accuracy | (TP + TN) / (TP + TN + FP + FN) | What percentage of predictions were completely correct? | — | Simple and intuitive — but can mislead on imbalanced data | Always predicting "not spam" is 95% accurate if only 5% of emails are spam |
| Precision | TP / (TP + FP) | Of everything predicted positive, how many were actually correct? | Very few false alarms | False positives are costly | Wrongly flagging a real email as spam |
| Recall | TP / (TP + FN) | Of everything actually positive, how many did the model catch? | Very few missed cases | False negatives are costly | Missing a genuinely fraudulent transaction |
| F1 score | 2 × (P × R) / (P + R) | The harmonic mean of precision and recall — balances both into one number | — | You care about both false positives and false negatives; especially on imbalanced datasets | — |
Which cells each metric divides by:
The lecture gives percentages only (5% spam, 95% accurate). Using 100 emails so the counts are whole numbers:
How it works with k = 5 — each round, a different fold (orange) is the test set:
train_test_split made one split (8 train / 2 test rows). k-fold repeats the split k times so every row gets a turn in the test set.The same training points, fit three ways:
| Overfitting | Underfitting | |
|---|---|---|
| What happens | Memorizes the training data too closely, including its noise and randomness | Too simple to capture the real pattern in the data |
| Training data | Performs great | Performs poorly |
| New, unseen data | Performs poorly | Performs poorly |
| Common causes | Too complex a model, or too little training data | Too simple a model, not enough training, or not enough relevant features |
| On a chart | A curve that fits every bump and noise point | A straight line through curved data — misses important structure |
| Key takeaway | Learns the noise instead of the signal; the goal is to generalize well to new, unseen data | High error on both training and new data |
| What to do | No fixes listed in the lecture | Use a more complex model; train longer; add more relevant features; reduce overly strong regularization |
Why avoiding overfitting matters: it leads to models that make better predictions in the real world and are more reliable and trustworthy.