Project

rcf

0.0
The project is in a healthy, maintained state
Random Cut Forest anomaly detection for Ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0
 Project Readme

Random Cut Forest Ruby

Random Cut Forest (RCF) anomaly detection for Ruby

Build Status

Installation

Add this line to your application’s Gemfile:

gem "rcf"

Getting Started

Create a forest with 3 dimensions

forest = Rcf::Forest.new(3)

Score a point

forest.score([1.0, 2.0, 3.0])

Update with a point

forest.update([1.0, 2.0, 3.0])

Example

forest = Rcf::Forest.new(3)

200.times do |i|
  point = [rand, rand, rand]

  # make the second to last point an anomaly
  if i == 198
    point[1] = 2
  end

  score = forest.score(point)
  puts "point = #{i}, score = #{score}"
  forest.update(point)
end

Parameters

Set parameters

Rcf::Forest.new(
  dimensions,
  shingle_size: 1,          # shingle size to use
  sample_size: 256,         # points to keep in sample for each tree
  number_of_trees: 100,     # number of trees to use in the forest
  random_seed: 42,          # random seed to use
  parallel: false           # enable parallel execution
)

References

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 https://github.com/ankane/random-cut-forest-ruby.git
cd random-cut-forest-ruby
bundle install
bundle exec rake vendor:all
bundle exec rake test