Skip to main content

Module anomaly

Module anomaly 

Source
Expand description

Unsupervised outlier detection.

Mahalanobis scores each row by its covariance-aware distance from the fitted centre; KnnScore by the distance to its k-th nearest training neighbour. Higher score = more anomalous. Both fit on a Frame and score a Frame, with a threshold turning scores into boolean flags.

(Isolation Forest is deferred until the tree ecosystem exposes the internals it needs; these two cover the common covariance / density cases.)

Structs§

KnnScore
k-nearest-neighbour distance scorer: each row scores as its distance to the k-th nearest training point. Isolated points score high.
Mahalanobis
Mahalanobis-distance outlier scorer: d(x) = sqrt((x-μ)ᵀ Σ⁻¹ (x-μ)).

Traits§

OutlierDetector
A common contract for unsupervised outlier scorers: fit on data, score each row (higher = more anomalous), and flag rows past a threshold. Implemented by Mahalanobis and KnnScore, so they are interchangeable behind Box<dyn OutlierDetector>.