AI and machine learning basics for security people
In short: Machine learning lets software learn patterns from data instead of following hand-written rules. Security tools use it to classify files, spot unusual behaviour and summarise alerts. To use these tools well you need to understand training data, error rates and the limits of any model.
AI, machine learning and deep learning
Artificial intelligence (AI) is the broad goal of making computers do tasks that normally need human judgement. Machine learning (ML) is the most common way of getting there today: instead of writing every rule by hand, you give an algorithm many examples and it builds a model that captures the patterns. Deep learning is a branch of ML that uses neural networks with many layers. It powers image recognition, speech-to-text and large language models (LLMs), the systems behind chat assistants.
A traditional antivirus signature says "if the file contains these exact bytes, it is malware". An ML classifier instead learns which combinations of features (file size, imported functions, entropy, behaviour) tend to appear in malware, so it can flag variants nobody has written a signature for yet.
How models learn
| Type | How it learns | Security example |
|---|---|---|
| Supervised | From examples already labelled with the right answer | Spam or not spam; malicious or benign URL |
| Unsupervised | Groups or profiles data with no labels | Clustering hosts by behaviour; spotting outliers in logins |
| Reinforcement | Tries actions and is rewarded for good outcomes | Research on automated defence and testing; rare in everyday products |
| Generative (deep learning) | Learns to produce new text, code or images | Alert summaries, query writing assistants, report drafts |
The quality of a model depends heavily on its training data. If the data is old, biased or mislabelled, the model learns the wrong lessons. Models also suffer from drift: the network changes, attackers change tactics, and accuracy slowly falls unless the model is retrained.
Judging a model: errors matter
Every classifier makes two kinds of mistake. A false positive flags something harmless as malicious; a false negative misses something malicious. Vendors often quote "accuracy", but on security data that can mislead. If only one event in ten thousand is malicious, a model that always says "benign" is 99.99% accurate and completely useless.
- Precision: of the things flagged, how many were really bad? Low precision means alert fatigue.
- Recall (detection rate): of the bad things, how many were caught? Low recall means missed attacks.
- Threshold: most models output a score. Moving the threshold trades precision against recall.
Tip: when evaluating a product, ask for precision and recall measured on data like yours, and run a trial on your own traffic before trusting any headline figure.
What this means at work and in exams
- ML is a tool, not magic. It works best alongside rules, threat intelligence and human analysts.
- Explainability matters. An analyst needs to know why something was flagged to act on it.
- Models are themselves a target. Attackers can try to evade, poison or steal them (see adversarial machine learning).
- LLMs generate plausible text, not verified facts. Check their output, especially commands and configurations.
A common exam mistake is mixing up supervised and unsupervised learning. Remember: supervised needs labelled data; unsupervised finds structure on its own and is often used for anomaly detection.
Practice
A model groups user logins into normal patterns and flags those that do not fit any group. Which type of learning is this?
Why is accuracy a poor measure for a malware detector?
What is model drift?
Key takeaways
- ML builds models from examples instead of hand-written rules.
- Supervised learning needs labels; unsupervised finds patterns without them.
- Judge detectors by precision, recall and false positive rate, not accuracy alone.
- Training data quality and drift decide how well a model works over time.
- Treat AI as one layer of defence, and remember models can be attacked too.
Original content written by Mohamed Fayas for FM TecHub. © 2026 FM TecHub. You're welcome to share a link to this page; please don't copy the text elsewhere without permission.