项目作者: oskanberg

项目描述 :
Extended Isolation Forest in go Go
高级语言: Go
项目地址: git://github.com/oskanberg/eif-go.git
创建时间: 2020-11-13T14:06:39Z
项目社区:https://github.com/oskanberg/eif-go

开源协议:MIT License

下载


PkgGoDev

Extended Isolation Forest

This is a simple Go implementation for the Extended Isolation Forest described in this paper. It is used for detecting anomalies and outliers in multidimensional data. Extended Isolation Forest in turn is an improvement on the Isolation Forest described in this paper.

This library currently only supports float64 type (of any dimension).

example plots showing anomaly scores

The authors of the Extended Isolation Forest have created a Python version of the algorithm.

Usage

  1. go get -u github.com/oskanberg/eif-go

Please refer to the godoc reference.

In this basic example, a forest is built from a set of random normally distributed 3D points:

  1. data := make([][]float64, 100)
  2. for i := range data {
  3. data[i] = []float64{rand.NormFloat64(), rand.NormFloat64(), rand.NormFloat64()}
  4. }
  5. f := eif.NewForest(data, eif.WithMaxTreeDepth(12), eif.WithTrees(100))
  6. fmt.Println(f.Score([]float64{0.0, 0.0, 0.0})) // 0.37800519781971176
  7. fmt.Println(f.Score([]float64{1.0, 1.0, 1.0})) // 0.4581319136519572
  8. fmt.Println(f.Score([]float64{100.0, 100.0, 100.0})) // 0.6520795100807051

Note that eif.WithMaxTreeDepth(12), eif.WithTrees(100) are optional parameters.