Foundation / Module 04

Measure the security decision, not just model accuracy

Build a practical mental model of supervised learning, anomaly detection, thresholds, drift, and the cost of false decisions.

60 minutes Beginner Practical lab
01

Match the method to the evidence

Supervised learning needs examples with labels that reflect the decision you want to automate. Unsupervised methods find structure or outliers without trustworthy labels. Semi-supervised and self-supervised methods can help when labels are scarce, but they do not remove the need to validate operational meaning.

In security, labels are delayed, incomplete, and influenced by existing detections. A model trained only on confirmed incidents can learn the blind spots of the current program.

  • Classification: predict a defined class from labeled examples.
  • Ranking: order alerts so scarce review time reaches the most useful cases.
  • Anomaly detection: identify deviations that require investigation, not automatic guilt.
  • Clustering: organize behavior or campaigns for analyst exploration.
  • Generation: produce hypotheses, summaries, or test cases that still require validation.
02

Neural networks learn representations, not explanations

A neural network combines layers of weighted transformations and non-linear activation functions. Training uses gradients to reduce a chosen loss on examples. Deeper networks can learn useful representations from images, text, audio, and sequences, but greater capacity also makes shortcuts, overfitting, and opaque failure harder to spot.

For a beginner security lab, a small model is usually better than a large one: it trains quickly, exposes the complete workflow, and makes baselines and failure analysis practical. A GPU can accelerate training, but it is not required to learn the concepts.

  • Input representation determines what the model can observe.
  • The loss function encodes which mistakes training tries to reduce.
  • Regularization and validation help detect memorization and overfitting.
  • Calibration asks whether confidence matches observed correctness.
  • Saving a model also creates a supply-chain artifact that needs provenance.
03

Accuracy can hide failure

When attacks are rare, a model that predicts normal every time can appear accurate. Precision answers how many flagged cases were relevant. Recall answers how many relevant cases were found. Neither should be optimized without the cost and capacity of the surrounding process.

A higher-recall detector may overwhelm analysts and lower total detection quality. A high-precision model may miss too many incidents. Choose thresholds with review capacity, response cost, and risk tolerance visible.

The best threshold is an operating decision, not a property the model discovers by itself.
04

Evaluate like production

Use time-based holdouts, entity-separated tests, realistic base rates, and representative failure cases. Compare against a simple rule or dummy baseline. Report confidence intervals or repeated-run variation rather than a single impressive score.

After deployment, watch feature drift, label delay, alert volume, override rate, and downstream outcome. A stable aggregate metric can conceal failure in a new region, user group, attack family, or software version.

Practice

Choose an alert threshold

Safety boundary: Use the synthetic login data from Module 03.

  1. 01

    Split records by time so later events form the test set.

  2. 02

    Train a simple baseline and produce probability scores.

  3. 03

    Compare at least three thresholds using precision, recall, and daily alert volume.

  4. 04

    Write the operational consequence of a false positive and false negative.

  5. 05

    Choose a threshold and document the condition that would trigger a review.

Checkpoint

Ready to move on?

Go deeper

Primary sources for this module

All resources
Previous module03 · Use Python to inspect security data, not to hide reasoning Next module05 · Understand the application wrapped around the LLM
Share this module LinkedIn Email Permanent link