Take a mid-sized organisation whose systems record ten million events a day: logins, file reads, network connections, processes starting. Suppose that on a given day one hundred of those events are part of something malicious.

A vendor offers a detector that is 99 per cent accurate. It catches 99 per cent of malicious events, and it wrongly flags only 1 per cent of harmless ones.

How many of its alerts are real?

Work it out before reading on. Most people's instinct says nearly all.

The arithmetic

Of the 100 malicious events, it catches 99.

Of the 9,999,900 harmless events, it flags 1 per cent, which is 99,999.

So the day's queue holds about 100,100 alerts, of which 99 are real. Roughly one alert in a thousand. A person who investigates alerts at one every five minutes, without a break, gets through about a hundred in a working day and will, on an average day, not meet a real one at all.

Nothing is wrong with the detector as specified. This is what 99 per cent means when the thing you are looking for is one in a hundred thousand. Statisticians call it the base-rate problem, and it applies equally to medical screening and airport security. In security it was set out clearly in the research literature a quarter of a century ago, and it still catches buyers out every year.

Why "accuracy" is the wrong word

A detector that never raises an alarm at all would be right about 9,999,900 events out of ten million. That is 99.999 per cent accuracy, better than the product above, for a device that does nothing.

When one class is rare, accuracy is close to meaningless. Two other numbers matter.

Recall: of the real attacks, what fraction did we flag? Above, 99 per cent.

Precision: of the things we flagged, what fraction were real? Above, about 0.1 per cent.

A product sheet that quotes detection rate without a false positive rate, and without saying how rare the attacks were in the test, has told you almost nothing. Ask for precision at a volume like yours.

To make the example workable, the false positive rate has to fall by orders of magnitude. At one in a hundred thousand, the same detector raises about 100 false alarms beside its 99 real ones, and half the queue is worth reading. Much of the real engineering in this field is that difference between 1 per cent and 0.001 per cent.

What the models actually do

There are two broad approaches, and they fail differently.

Supervised learning trains on labelled examples of bad and good. It works well for things that recur in quantity, such as spam, phishing pages and known families of malware. It is weak against what it has never seen, and labelled examples of real intrusions are scarce.

Anomaly detection needs no labels. It learns what normal looks like and flags departures: a user who logs in at an hour they never have, a server that begins sending far more data out than usual, a process that has not run on this machine before.

The methods range from simple to elaborate. A threshold on how far a value lies from its usual range. Clustering, with attention to points that belong to no cluster. Isolation forests, which rest on the observation that unusual points are easy to separate from the rest with a few random cuts. Neural networks trained to reproduce normal data, which do it badly when shown something odd.

All of them share one difficulty, and it is not mathematical. Unusual is not the same as malicious. A real network is full of harmless novelty: someone working from an airport, a new backup job, a software update, the finance team at quarter end. And a careful intruder works hard to look ordinary, using valid credentials and the administrator's own tools at a plausible hour.

So anomaly detection produces exactly the false positives the arithmetic punishes, and can still miss the patient attacker.

What happens to people

The cost of a false alarm is not only the minutes spent on it. A queue that is almost entirely noise teaches the people reading it that alerts are noise. They skim, then they close in bulk, and then a real one goes past in the stream.

Several well-documented breaches include a line to the effect that the system did raise an alert, and nobody acted on it. The detector worked, and the organisation was still undefended, because the alert was one of thousands.

Any honest assessment of a detection system therefore has to include the capacity of the people at the other end.

What helps

Start from the capacity. If the team can properly investigate thirty alerts a day, that is the budget. Set thresholds to produce about thirty, and accept openly that some things will be missed. That is a better position than three thousand alerts and an illusion of coverage.

Narrow the question. A model watching everything has a hopeless base rate. A model watching only administrator logins to the dozen most sensitive servers has far fewer events and a much higher proportion that matter.

Combine weak signals. One odd thing is usually nothing. A first-time login from a new country, followed by a mailbox rule being created, followed by a large download, is a story. Scoring sequences and combinations raises precision far more than tuning any single detector.

Add context before a person sees it. Is this machine a developer's laptop or a payroll server? Is the user on leave? Was there a change approved for tonight? Much of what an analyst does in the first five minutes can be attached automatically.

Close the loop. Record how every alert was resolved. Rules and models that are wrong ninety-nine times in a hundred get fixed or switched off. Without that record, queues only grow.

Keep the dull controls. Detection is what you do about the attacks that got in. Fewer get in when software is patched, access is limited to what each person needs, and second factors are required. Those measures also shrink the number of events worth watching, which improves the base rate for everything else.

The questions to ask a vendor

  1. What is the false positive rate, per day, at ten million events?
  2. How rare were attacks in the data you tested on?
  3. What does an alert contain, and how long does one take to assess?
  4. How does it behave in its first month, before it knows what is normal here?
  5. What happens when our environment changes?

A supplier with good answers will be pleased to be asked. Machine learning has real uses in defence. But the arithmetic of rare events applies to every product in this field, including the good ones, so it should be worked through before the purchase.