Free tech learning for everyone, from basics to pro

AI & Cyber SecurityEmerging Technologies and SecurityBeginner

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.

Main types of machine learningMachine learninglearns from dataSupervisedlabelled examplesUnsupervisedfinds structureReinforcementtrial and rewardDeep learningmany-layer networks
Figure 1. The main families of machine learning, grouped by how the model learns from data.

How models learn

TypeHow it learnsSecurity example
SupervisedFrom examples already labelled with the right answerSpam or not spam; malicious or benign URL
UnsupervisedGroups or profiles data with no labelsClustering hosts by behaviour; spotting outliers in logins
ReinforcementTries actions and is rewarded for good outcomesResearch on automated defence and testing; rare in everyday products
Generative (deep learning)Learns to produce new text, code or imagesAlert summaries, query writing assistants, report drafts
A typical ML workflowCollectdatalogs,samplesPrepareclean, labelTrainfit themodelEvaluatetest onunseen dataDeployscore liveeventsMonitorwatch fordrift
Figure 2. A machine learning project moves from data collection to a monitored model in production.

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?
Unsupervised learning used for anomaly detection, because no labelled examples of attacks are needed.
Why is accuracy a poor measure for a malware detector?
Malicious samples are rare, so a model can score very high accuracy while missing most attacks. Precision and recall show the real trade-off.
What is model drift?
The gradual fall in a model’s performance as real-world data changes away from the data it was trained on.

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.
Tracks your learning on this device only. See your progress on the learning paths.

About the author

Mohamed Fayas

Founder of FM TecHub. CCNA certified, with a BTEC HND in Network Engineering, and BEng (Hons) in Computer Networking and Cloud Security. He writes practical, plain-English guides on networking, security and cloud.

More about the author

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.

Stay up to date by email

New notes, tools and security news from FM TecHub, explained simply. Free.

We only use your email to send these updates. See our privacy policy.