Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ankane/trend-ruby
Anomaly detection and forecasting for Ruby
https://github.com/ankane/trend-ruby
Last synced: 13 days ago
JSON representation
Anomaly detection and forecasting for Ruby
- Host: GitHub
- URL: https://github.com/ankane/trend-ruby
- Owner: ankane
- License: mit
- Created: 2018-05-24T05:05:27.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-05-03T19:00:42.000Z (6 months ago)
- Last Synced: 2024-05-03T20:41:07.608Z (6 months ago)
- Language: Ruby
- Homepage: https://trendapi.org
- Size: 29.3 KB
- Stars: 132
- Watchers: 8
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Trend Ruby
Ruby client for [Trend](https://github.com/ankane/trend-api), the anomaly detection and forecasting API
**Note: The [hosted version](https://trendapi.org/) is no longer available. [See how to run the API on your own infrastructure.](https://github.com/ankane/trend-api)**
[![Build Status](https://github.com/ankane/trend-ruby/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/trend-ruby/actions)
## Installation
Add this line to your application’s Gemfile:
```ruby
gem "trend"
```And set the URL to the API:
```ruby
Trend.url = "http://localhost:8000"
```## Anomaly Detection
Detect anomalies in a time series
```ruby
# generate series
series = {}
date = Date.parse("2023-04-01")
28.times do
series[date] = rand(100)
date += 1
end# add an anomaly on Apr 21
series[date - 8] = 999Trend.anomalies(series)
```Works great with [Groupdate](https://github.com/ankane/groupdate)
```ruby
series = User.group_by_day(:created_at).count
Trend.anomalies(series)
```## Forecasting
Get future predictions for a time series
```ruby
series = {}
date = Date.parse("2023-04-01")
28.times do
series[date] = date.wday
date += 1
endTrend.forecast(series)
```Also works great with Groupdate
```ruby
series = User.group_by_day(:created_at).count
Trend.forecast(series)
```Specify the number of predictions to return
```ruby
Trend.forecast(series, count: 3)
```## Correlation [experimental]
Get the correlation between two time series
```ruby
Trend.correlation(series, series2)
```## History
View the [changelog](https://github.com/ankane/trend-ruby/blob/master/CHANGELOG.md)
## Contributing
Everyone is encouraged to help improve this project. Here are a few ways you can help:
- [Report bugs](https://github.com/ankane/trend-ruby/issues)
- Fix bugs and [submit pull requests](https://github.com/ankane/trend-ruby/pulls)
- Write, clarify, or fix documentation
- Suggest or add new featuresTo get started with development:
```sh
git clone https://github.com/ankane/trend-ruby.git
cd trend-ruby
bundle install
bundle exec rake test
```