README

MIDAS

This is an implementation of MIDAS - edge stream anomaly detection but implemented in Go.

For more information about how it works, please checkout the resources section.

Usage and installation

Read the docs

Checkout the examples folder for detailed instructions

import (
	"github.com/steve0hh/midas"
	"fmt"
)

func main () {
	src := []int{2,2,3,3,5,5,7,11,1,2}
	dst := []int{3,3,4,4,9,9,73,74,75,76}
	times := []int{1,1,2,2,2,2,2,2,2,2}


	// using function to score the edges
	midasAnormScore := midas.Midas(src, dst, times, 2, 769)
	midasRAnormScore := midas.MidasR(src, dst, times, 2, 769, 0.6)

	fmt.Println(midasAnormScore)
	fmt.Println(midasRAnormScore)

	// using sklearn FitPredict api for midas
	m := midas.NewMidasModel(2, 769, 9460)
	fmt.Println(m.FitPredict(2,3,1))
	fmt.Println(m.FitPredict(2,3,1))
	fmt.Println(m.FitPredict(3,4,2))

	// using sklearn FitPredict api for midasR
	mr := midas.NewMidasRModel(2, 769, 9460, 0.6)
	fmt.Println(mr.FitPredict(2,3,1))
	fmt.Println(mr.FitPredict(2,3,1))
	fmt.Println(mr.FitPredict(3,4,2))
}

Resources

Citation

If you use this code for your research, please consider citing the original paper.

@article{bhatia2019midas,
  title={MIDAS: Microcluster-Based Detector of Anomalies in Edge Streams},
  author={Bhatia, Siddharth and Hooi, Bryan and Yoon, Minji and Shin, Kijung and Faloutsos, Christos},
  journal={arXiv preprint arXiv:1911.04464},
  year={2019}
}

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

  • Report bugs
  • Fix bugs and submit pull requests
  • Write, clarify, or fix documentation
  • Suggest or add new features

TODOs

  • Godocs documentation
  • Add sklearn/keras fit & predict API
  • More examples and tests
  • Make code more efficient
Expand ▾ Collapse ▴

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Midas

func Midas(src []int, dst []int, times []int, numRows int, numBuckets int) []float64

    Takes in a list of source, destination and times to do anomaly score of each edge This function mirrors the implementation of https://github.com/bhatiasiddharth/MIDAS

    func MidasR

    func MidasR(src []int, dst []int, times []int, numRows int, numBuckets int, factor float64) []float64

    Types

    type EdgeHash

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

    func NewEdgeHash

    func NewEdgeHash(numRows int, numBuckets int, m int) *EdgeHash

    func (*EdgeHash) Clear

    func (e *EdgeHash) Clear()

    func (*EdgeHash) GetCount

    func (e *EdgeHash) GetCount(a int, b int) float64

    func (*EdgeHash) Hash

    func (e *EdgeHash) Hash(a int, b int, i int) int

    func (*EdgeHash) Insert

    func (e *EdgeHash) Insert(a int, b int, weight float64)

    func (*EdgeHash) Lower

    func (e *EdgeHash) Lower(factor float64)

    type MidasModel

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

    func NewMidasModel

    func NewMidasModel(numRows int, numBuckets int, m int) *MidasModel

      Creates a new Midas struct that will enable the use of Fit and FitPredict API.

      func (*MidasModel) Fit

      func (m *MidasModel) Fit(src, dst, time int)

        Fit the source, destination and time to the MidasModel struct similar to the sklearn api

        func (*MidasModel) FitPredict

        func (m *MidasModel) FitPredict(src, dst, time int) float64

          Fit the source, destination and time to the MidasModel struct and calculate the anomaly score

          type MidasRModel

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

          func NewMidasRModel

          func NewMidasRModel(numRows int, numBuckets int, m int, factor float64) *MidasRModel

          func (*MidasRModel) Fit

          func (m *MidasRModel) Fit(src, dst, time int)

          func (*MidasRModel) FitPredict

          func (m *MidasRModel) FitPredict(src, dst, time int) float64

          type NodeHash

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

          func NewNodeHash

          func NewNodeHash(numRows int, numBuckets int) *NodeHash

          func (*NodeHash) Clear

          func (n *NodeHash) Clear()

          func (*NodeHash) GetCount

          func (n *NodeHash) GetCount(a int) float64

          func (*NodeHash) Hash

          func (n *NodeHash) Hash(a int, i int) int

          func (*NodeHash) Insert

          func (n *NodeHash) Insert(a int, weight float64)

          func (*NodeHash) Lower

          func (n *NodeHash) Lower(factor float64)

          Directories

          Path Synopsis