README.md in isotree-0.1.2 vs README.md in isotree-0.1.3

- old
+ new

@@ -2,10 +2,12 @@ :evergreen_tree: [IsoTree](https://github.com/david-cortes/isotree) - outlier/anomaly detection using Isolation Forest - for Ruby Learn how [Isolation Forest](https://www.youtube.com/watch?v=RyFQXQf4w4w) works +:deciduous_tree: Check out [OutlierTree](https://github.com/ankane/outliertree) for human-readable explanations of outliers + [![Build Status](https://travis-ci.org/ankane/isotree.svg?branch=master)](https://travis-ci.org/ankane/isotree) ## Installation Add this line to your application’s Gemfile: @@ -17,24 +19,28 @@ ## Getting Started Prep your data ```ruby -x = [[1, 2], [3, 4], [5, 6], [7, 8]] +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 ```ruby model = IsoTree::IsolationForest.new -model.fit(x) +model.fit(data) ``` Get outlier scores ```ruby -model.predict(x) +model.predict(data) ``` Scores are between 0 and 1, with higher scores indicating outliers ## Parameters @@ -65,16 +71,26 @@ See a [detailed explanation](https://isotree.readthedocs.io/en/latest/#isotree.IsolationForest) ## Data -Data can be an array of arrays +Data can be an array of hashes ```ruby -[[1, 2, 3], [4, 5, 6]] +[ + {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 + +```ruby +Rover.read_csv("data.csv") +``` + Or a Numo array ```ruby Numo::NArray.cast([[1, 2, 3], [4, 5, 6]]) ``` @@ -90,9 +106,17 @@ Then reinstall the gem. ```sh gem uninstall isotree --force bundle install +``` + +## Reference + +Get the average isolation depth + +```ruby +model.predict(data, output: "avg_depth") ``` ## History View the [changelog](https://github.com/ankane/isotree/blob/master/CHANGELOG.md)