go-iforest – github.com/codegaudi/go-iforest Index | Files

package go_iforest

import "github.com/codegaudi/go-iforest"

Package go_iforest is an implementation of isolation forests as defined in https://cs.nju.edu.cn/zhouzh/zhouzh.files/publication/icdm08b.pdf.

Index

Constants

const EulersConstant = 0.5772156649

Variables

var (
	ErrTooLargeSubSamplingSize = errors.New("specified sub-sampling size is larger than amount of provided samples")
	ErrNoSamplesProvided       = errors.New("no samples provided")
)

Functions

func PathLength

func PathLength(x []float64, T *Node, e int) float64

PathLength derives the path length for an instance x using a Tree T e is the current path length (0 on the first call to this method)

Types

type IForest

type IForest struct {
	Trees           []*ITree
	SubSamplingSize int
}

func NewIForest

func NewIForest(X [][]float64, trees int, subSamplingSize int) (*IForest, error)

NewIForest creates a new IForest and trains it on the provided data X make sure to call rand.Seed() before calling this function to ensure that a sufficiently random sub-sample is chosen.

func (*IForest) CalculateAnomalyScore

func (f *IForest) CalculateAnomalyScore(x []float64) float64

CalculateAnomalyScore calculates an anomaly score based for a sample x

type ITree

type ITree struct {
	// contains filtered or unexported fields
}

func NewITree

func NewITree(X [][]float64) *ITree

type Node

type Node struct {
	// contains filtered or unexported fields
}

Source Files

errors.go iforest.go itree.go

Version
v0.0.1 (latest)
Published
Jan 17, 2021
Platform
linux/amd64
Imports
3 packages
Last checked
2 weeks ago

Tools for package owners.