0.01
The project is in a healthy, maintained state
Explainable outlier/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

>= 4.3
 Project Readme

OutlierTree Ruby

🌳 OutlierTree - explainable outlier/anomaly detection - for Ruby

Produces human-readable explanations for why values are detected as outliers

Price (2.50) looks low given Department is Books and Sale is false

🌲 Check out IsoTree for an alternative approach that uses Isolation Forest

Build Status

Installation

Add this line to your application’s Gemfile:

gem "outliertree"

Getting Started

Prep your data

data = [
  {department: "Books",  sale: false, price: 2.50},
  {department: "Books",  sale: true,  price: 3.00},
  {department: "Movies", sale: false, price: 5.00},
  # ...
]

Train a model

model = OutlierTree.new
model.fit(data)

Get outliers

model.outliers(data)

Parameters

Pass parameters - default values below

OutlierTree.new(
  max_depth: 4,
  min_gain: 0.01,
  z_norm: 2.67,
  z_outlier: 8.0,
  pct_outliers: 0.01,
  min_size_numeric: 25,
  min_size_categ: 50,
  categ_split: "binarize",
  categ_outliers: "tail",
  numeric_split: "raw",
  follow_all: false,
  gain_as_pct: true,
  nthreads: -1
)

See a detailed explanation

Data

Data can be an array of hashes

[
  {department: "Books",  sale: false, price: 2.50},
  {department: "Books",  sale: true,  price: 3.00},
  {department: "Movies", sale: false, price: 5.00}
]

Or a Rover data frame

Rover.read_csv("data.csv")

Performance

OutlierTree uses OpenMP when possible for best performance. To enable OpenMP on Mac, run:

brew install libomp

Then reinstall the gem.

gem uninstall outliertree --force
bundle install

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