Skip to content

Edge stream anomaly detection for Ruby

License

Notifications You must be signed in to change notification settings

stjordanis/midas-1

 
 

MIDAS

MIDAS - edge stream anomaly detection - for Ruby

Build Status

Installation

Add these lines to your application’s Gemfile:

gem 'midas-edge'
gem 'rice', github: 'jasonroelofs/rice' # for now for c++17

Getting Started

Prep your data in the format [source, destination, time] (all integers) and sorted by time (ascending)

data = [
  [2, 3, 1],
  [3, 4, 2],
  [5, 9, 2],
  [2, 3, 3]
]

Get anomaly scores

midas = Midas.new
scores = midas.fit_predict(data)

Higher scores are more anomalous. There is not currently a defined threshold for anomalies.

Parameters

Pass parameters - default values below

Midas.new(
  rows: 2,           # number of hash functions
  buckets: 769,      # number of buckets
  alpha: 0.5,        # temporal decay factor
  threshold: nil,    # todo
  relations: true,   # whether to use MIDAS-R or MIDAS
  directed: true,    # treat the graph as directed or undirected
  seed: 0            # random seed
)

Data

Data can be an array of arrays

[[1, 2, 3], [4, 5, 6]]

Or a Numo array

Numo::NArray.cast([[1, 2, 3], [4, 5, 6]])

Performance

For large datasets, read data directly from files

midas.fit_predict("data.csv")

Resources

History

View the changelog

Contributing

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

To get started with development:

git clone --recursive https://github.com/ankane/midas.git
cd midas
bundle install
bundle exec rake compile
bundle exec rake test

About

Edge stream anomaly detection for Ruby

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 60.4%
  • C++ 39.6%