README.md in anomaly-0.1.0 vs README.md in anomaly-0.2.0
- old
+ new
@@ -1,36 +1,24 @@
# Anomaly
Easy-to-use anomaly detection
+[![Build Status](https://travis-ci.org/ankane/anomaly.svg?branch=master)](https://travis-ci.org/ankane/anomaly)
+
## Installation
-Add this line to your application's Gemfile:
+Add this line to your application’s Gemfile:
```ruby
gem "anomaly"
```
-And then execute:
+## Getting Started
-```sh
-bundle install
-```
+Say we have weather data and we want to predict if it’s sunny. In this example, sunny days are non-anomalies, and days with other types of weather (rain, snow, etc.) are anomalies. The data looks like:
-For max performance (trains ~3x faster for large datasets), also install the NArray gem:
-
```ruby
-gem "narray"
-```
-
-Anomaly will automatically detect it and use it.
-
-## How to Use
-
-Say we have weather data and we want to predict if it's sunny. In this example, sunny days are non-anomalies, and days with other types of weather (rain, snow, etc.) are anomalies. The data looks like:
-
-```ruby
# [temperature(°F), humidity(%), pressure(in), sunny?(y=0, n=1)]
weather_data = [
[85, 68, 10.4, 0],
[88, 62, 12.1, 0],
[86, 64, 13.6, 0],
@@ -42,56 +30,55 @@
The last column **must** be 0 for non-anomalies, 1 for anomalies. Non-anomalies are used to train the detector, and both anomalies and non-anomalies are used to find the best value of ε.
To train the detector and test for anomalies, run:
```ruby
-ad = Anomaly::Detector.new(weather_data)
+detector = Anomaly::Detector.new(weather_data)
# 85°F, 42% humidity, 12.3 in. pressure
-ad.anomaly?([85, 42, 12.3])
-# => true
+detector.anomaly?([85, 42, 12.3])
```
Anomaly automatically finds the best value for ε, which you can access with:
```ruby
-ad.eps
+detector.eps
```
If you already know you want ε = 0.01, initialize the detector with:
```ruby
-ad = Anomaly::Detector.new(weather_data, {:eps => 0.01})
+detector = Anomaly::Detector.new(weather_data, eps: 0.01)
```
-### Persistence
+## Persistence
-You can easily persist the detector to a file or database - it's very tiny.
+You can easily persist the detector to a file or database - it’s very tiny.
```ruby
-serialized_ad = Marshal.dump(ad)
+dump = Marshal.dump(detector)
+File.binwrite("detector.dump", dump)
+```
-# Save to a file
-File.open("anomaly_detector.dump", "w") {|f| f.write(serialized_ad) }
+Then read it later:
-# ...
-
-# Read it later
-ad2 = Marshal.load(File.open("anomaly_detector.dump", "r").read)
+```ruby
+dump = File.binread("detector.dump")
+detector = Marshal.load(dump)
```
-## TODO
+## Credits
-- Train in chunks (for very large datasets)
-- Multivariate normal distribution (possibly)
+A special thanks to [Andrew Ng](http://www.ml-class.org).
-## Contributing
+## History
-1. Fork it
-2. Create your feature branch (`git checkout -b my-new-feature`)
-3. Commit your changes (`git commit -am 'Added some feature'`)
-4. Push to the branch (`git push origin my-new-feature`)
-5. Create new Pull Request
+View the [changelog](https://github.com/ankane/anomaly/blob/master/CHANGELOG.md)
-## Thanks
+## Contributing
-A special thanks to [Andrew Ng](http://www.ml-class.org).
+Everyone is encouraged to help improve this project. Here are a few ways you can help:
+
+- [Report bugs](https://github.com/ankane/anomaly/issues)
+- Fix bugs and [submit pull requests](https://github.com/ankane/anomaly/pulls)
+- Write, clarify, or fix documentation
+- Suggest or add new features