Unit Summary and Quick Reference
| Topic | Core idea |
|---|---|
| Three ML families | Supervised (labelled), unsupervised (unlabelled), reinforcement (reward-driven) learning, each matched to a different security problem in this course |
| Four threat families | Malware, social engineering, network intrusion, and fraud/abuse, each favouring a different family of model |
| The spam arms race | Paul Graham's 2002 Naive Bayes approach to spam outlasted keyword blacklists because it learns from data rather than a fixed rule list |
| The ML pipeline | Collect, engineer features, train, evaluate, deploy and monitor, the five stages every unit in this course builds |
| Class imbalance | Even ordinary spam data is imbalanced; fraud and intrusion data are far more so, a theme that returns in Units 2 and 6 |
Self-Study Questions
Q1. Why does a keyword blacklist eventually fail against a motivated spammer, even one with no technical sophistication?
A blacklist only blocks exactly what it was told to block, specific sender addresses or specific words. It has no memory of anything it was not explicitly given. A spammer who misspells a blocked word or rotates to a fresh, unlisted sending address slips past it entirely, with no need for any technical sophistication, just small variation.
Q2. Name the three families of machine learning used in this course, and match each to the kind of training data it requires.
Supervised learning requires already-labelled data, such as emails marked spam or legitimate. Unsupervised learning requires no labels at all; the model finds structure on its own. Reinforcement learning requires no fixed dataset at all; an agent takes actions in an environment and learns from the rewards it observes over time.
Q3. Why might a security dataset be described as "imbalanced," and why does this matter for a model's evaluation, not just its training?
A dataset is imbalanced when one class, such as spam, fraud, or intrusion traffic, is far rarer than the other. This matters for evaluation because a model can achieve a very high accuracy score simply by predicting the majority class every time, while being useless at catching the rare, important class. Unit 6 covers metrics built specifically to expose this.
Q4. Walk through the five-stage ML pipeline for a network intrusion detection system: what would "collect," "engineer features," and "deploy and monitor" concretely mean in that setting?
Collect would mean gathering raw network traffic, such as packet captures or flow records. Engineer features would mean turning that raw traffic into numeric measurements a model can use, such as packet counts, connection duration, or protocol flags. Deploy and monitor would mean running the trained detector on live traffic while tracking whether its accuracy holds up as network behaviour and attacker techniques drift over time, retraining when it does not.
Q5. Pick any two non-adjacent stages of the Cyber Kill Chain and explain, for each, which family of machine learning from this unit would help a defender most, and why.
Reconnaissance is best addressed by unsupervised anomaly detection (Unit 3), since scanning traffic has no fixed label and needs to be flagged as unusual relative to a baseline. Delivery is best addressed by supervised learning (Unit 1, Unit 5), since phishing and spam classifiers are trained on labelled examples of malicious versus legitimate messages.
Q6. Using the timeline figure, explain in your own words why offensive and defensive machine learning milestones tend to alternate rather than one side simply winning permanently.
Every defensive advance, such as a new statistical spam filter or malware classifier, creates an incentive and a target for attackers to find a way around it, and every successful attack then creates pressure for a stronger defensive response. This is the same arms-race dynamic security has always had, now playing out between models as well as between humans, which is why the timeline shows offensive and defensive milestones pushing each other forward rather than either side settling the matter once and for all.
Lab: Extend the Spam Classifier
- Reproduce the baseline. Using the
naive_bayes_spam.pyscript from this unit, train the classifier on any public spam/ham dataset (such as the classic SpamAssassin public corpus) and confirm you can reproduce a classification report in the same shape as the one shown in this unit. - Break the blacklist on purpose. Take five sentences the blacklist filter correctly flags, and rewrite each one with a single character substitution (e.g. "viagra" to "v1agra"). Run both
is_spam_blacklistand the trained Naive Bayes classifier on your rewritten sentences and record which one still catches them. - Measure the imbalance. Count the exact number of spam versus legitimate messages in whichever dataset you used, and compare the ratio to the 4,827 to 1,813 (roughly 3 to 1) ratio shown in this unit's chart.
- Map one real tool. Pick one security product you have used (an email provider, an antivirus, a bank's fraud alert) and write two sentences on which threat family from this unit it defends against and which family of machine learning it most likely uses.

