Skip to content

ankane/midas-ruby

Repository files navigation

MIDAS Ruby

MIDAS - edge stream anomaly detection - for Ruby

Build Status

Installation

Add this line to your application’s Gemfile:

gem "midas-edge"

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-ruby.git
cd midas-ruby
bundle install
bundle exec rake compile
bundle exec rake test

About

Edge stream anomaly detection for Ruby

Resources

License

Stars

Watchers

Forks

Packages

No packages published