How anomaly detection actually works
Anomaly detection looks like a classification problem — is this transaction fraudulent, is this sensor reading a failure — but it almost never gets treated as one, for a simple reason: anomalies are rare and usually unlabeled. You can't train a classifier to recognize fraud patterns you've never seen examples of.
Why "just label the anomalies" doesn't work
Standard classification needs a reasonable number of labeled examples of every class it predicts. Fraud, equipment failure, and intrusion attempts are specifically the events a business doesn't have many confirmed, well-labeled examples of — and the ones that matter most are often novel: a fraud pattern or failure mode nobody has seen yet is exactly what you need to catch. That rules out "train a classifier on known bad examples" as a complete strategy.
The statistical approach
The simplest real technique is to model what normal looks like and flag anything that deviates significantly. A z-score flags a data point based on how many standard deviations it sits from the mean; the interquartile range (IQR) method flags points far outside the typical spread, which handles skewed data better than a plain mean-and-standard-deviation approach. Both assume you can define "normal" numerically for a single variable, which works well for something like server response time but breaks down when "normal" depends on the relationship between many variables at once.
The model-based approach
Isolation forests work differently: instead of defining normal, they exploit the fact that anomalies are easier to separate from the rest of the data than typical points are. Randomly partitioning the data isolates an outlier in fewer steps than it isolates a typical point, and that count becomes the anomaly score. Autoencoders take a different angle — a neural network learns to compress and reconstruct normal data well; when it reconstructs a new input poorly, that reconstruction error is the signal that something doesn't fit the learned pattern.
The trade-off that never goes away
Every anomaly detection system balances two costs that pull in opposite directions: missing a real anomaly (a false negative — the expensive kind, since it's often the thing the system exists to catch) against flagging normal behaviour as anomalous (a false positive — which erodes trust in the system and wastes the time of whoever reviews alerts). There's no setting that eliminates both; tightening the threshold to catch more real anomalies always means more false alarms, and the right balance depends entirely on which mistake costs more in a given context — missing fraud is not the same cost as missing a minor sensor glitch.