Lightweight Online Detector of Anomalies uses a series of sparse random projection vectors to produce scalar inputs to an ensemble of unique one-dimensional equi-width histograms. The histograms are then used to estimate the probability density of an unknown sample during inference.

Interfaces: Estimator, Learner, Online, Ranking, Persistable

Data Type Compatibility: Continuous


# Param Default Type Description
1 estimators 100 int The number of projection/histogram pairs in the ensemble.
2 bins null int The number of equi-width bins for each histogram. If null then will estimate bin count.
3 contamination 0.1 float The proportion of outliers that are assumed to be present in the training set.


use Rubix\ML\AnomalyDetectors\Loda;

$estimator = new Loda(250, 8, 0.01);

Additional Methods#

To estimate the number of histogram bins from the number of samples in a dataset:

public static estimateBins(int $n) : int


  • T. Pevný. (2015). Loda: Lightweight on-line detector of anomalies.
  • L. Birg´e et al. (2005). How Many Bins Should Be Put In A Regular Histogram.