Giter VIP home page Giter VIP logo

midas-ruby's Introduction

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

midas-ruby's People

Contributors

ankane avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

midas-ruby's Issues

Rice Fixes

@ankane - To get the new version of Rice working, remove the *[] to lambdas. If you want a pointer the syntax you can use is +[]. See:

https://stackoverflow.com/questions/18889028/a-positive-lambda-what-sorcery-is-this

But really you need neither, just use a lambda. Note a good post about what is really happening under the covers here:

https://devblogs.microsoft.com/oldnewthing/20150220-00/?p=44623

Next, change the calls from define_method to define_function since there is no "self" object you are passing around. define_method adds an implicit self parameter to the front of the argument list while define_self does not.

Also, I would recommend not naming the extension ext - that seems to be asking for conflicts with other gems. I'd call it something like midas, so you end up with midas.so.

Updated file attached (I did one lambda as +[] and one without...but I would do both without).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.