Ruby client for Trend, the anomaly detection and forecasting API
Note: The hosted version is no longer available. See how to run the API on your own infrastructure.
Add this line to your application’s Gemfile:
gem "trend"
And set the URL to the API:
Trend.url = "http://localhost:8000"
Detect anomalies in a time series
# generate series
series = {}
date = Date.parse("2025-01-01")
28.times do
series[date] = rand(100)
date += 1
end
# add an anomaly on Apr 21
series[date - 8] = 999
Trend.anomalies(series)
Works great with Groupdate
series = User.group_by_day(:created_at).count
Trend.anomalies(series)
Get future predictions for a time series
series = {}
date = Date.parse("2025-01-01")
28.times do
series[date] = date.wday
date += 1
end
Trend.forecast(series)
Also works great with Groupdate
series = User.group_by_day(:created_at).count
Trend.forecast(series)
Specify the number of predictions to return
Trend.forecast(series, count: 3)
Get the correlation between two time series
Trend.correlation(series, series2)
View the changelog
Everyone is encouraged to help improve this project. Here are a few ways you can help:
- Report bugs
- Fix bugs and submit pull requests
- Write, clarify, or fix documentation
- Suggest or add new features
To get started with development:
git clone https://github.com/ankane/trend-ruby.git
cd trend-ruby
bundle install
bundle exec rake test