Three settings
The topic Dimensionality reduction ended with models that are densities. Probabilistic PCA and the Gaussian mixture of Mixtures and the EM algorithm say not only where the data lie but how probable each point is. A fraudulent payment, a failing sensor, a corrupted record or a network intrusion is usually a point that such a model finds improbable. Anomaly detection turns this into a method.
Every detector in this topic does the same two things. It gives each point an anomaly score , higher for points that do not fit. Then it flags when for a threshold . Where labels exist, marks a true anomaly and a normal point.
Anomalies are rare, varied and often new, so labelled examples of them are scarce. What can be learned depends on what is labelled.
- Supervised. Both normal points and anomalies are labelled. This is classification with very unequal classes, handled with class weights and the metrics of Classification metrics. It finds the kinds of anomalies it was shown and can miss new kinds.
- Novelty detection. The training set holds only normal points, known to be clean. The model describes them, and a new point is flagged if it does not fit the description. Most methods below are built for this setting.
- Outlier detection. The training set is unlabelled and contaminated with a small share of anomalies, the contamination. The task is to find them in the same data. The methods are the same, but they are fitted on the very anomalies they must find.
Most methods look for point anomalies, points unusual in themselves. A contextual anomaly is unusual only in a context: C is normal in January and alarming in July. Adding the context as a feature, or modelling the distribution given the context, reduces it to a point anomaly.
Like a cluster, "does not fit" has no single definition. Each family of scores below picks one: low density, far from the neighbours, quick to isolate, outside a learned boundary.