mitcelab / anomalous

Anomaly detection in Go with isolation forests.
7 stars 4 forks source link
anomaly-detection isolation-forest

anomalous

Build Status GoDoc

Anomaly detection in Go with isolation forests.

install

go install github.com/mitcelab/anomalous

usage

X := [][]float64{
    {1.0, 0.0, 0.0},
    {1.0, 1.0, 0.0},
    {1.0, 2.0, 0.0},
    {1.0, 3.0, 0.0},
    {1.0, 4.0, 0.0},
    {1.0, 5.0, 0.0},
}
detector := NewDetector(X)

positive := detector.Predict(X[0])
maybe := detector.Predict([]float64{1.0, 4.5, 0.0})
no := detector.Predict([]float64{1.0, 4.5, 1.0})

if positive > maybe {
    log.Fatal("the `maybe` sample should have higher anomaly probability")
}

if maybe > no {
    log.Fatal("the `no` sample should have a *much* higher anomaly probability")
}