{"id":15648055,"url":"https://github.com/ankane/anomalydetection.rb","last_synced_at":"2025-11-17T14:14:21.857Z","repository":{"id":56842444,"uuid":"417637087","full_name":"ankane/AnomalyDetection.rb","owner":"ankane","description":"Time series anomaly detection for Ruby","archived":false,"fork":false,"pushed_at":"2025-02-24T18:51:35.000Z","size":126,"stargazers_count":44,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-30T03:09:43.248Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ankane.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-15T21:10:38.000Z","updated_at":"2025-02-24T18:51:39.000Z","dependencies_parsed_at":"2023-12-26T17:48:44.782Z","dependency_job_id":"cef07272-650a-4ff0-a9e4-59aa5e20899d","html_url":"https://github.com/ankane/AnomalyDetection.rb","commit_stats":{"total_commits":65,"total_committers":1,"mean_commits":65.0,"dds":0.0,"last_synced_commit":"979909de84f68419d8684f031db75e757299d059"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2FAnomalyDetection.rb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2FAnomalyDetection.rb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2FAnomalyDetection.rb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2FAnomalyDetection.rb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ankane","download_url":"https://codeload.github.com/ankane/AnomalyDetection.rb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247430963,"owners_count":20937875,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T12:23:02.611Z","updated_at":"2025-11-17T14:14:21.818Z","avatar_url":"https://github.com/ankane.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AnomalyDetection.rb\n\n:fire: Time series [AnomalyDetection](https://github.com/twitter/AnomalyDetection) for Ruby\n\nLearn [how it works](https://blog.twitter.com/engineering/en_us/a/2015/introducing-practical-and-robust-anomaly-detection-in-a-time-series)\n\n[![Build Status](https://github.com/ankane/AnomalyDetection.rb/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/AnomalyDetection.rb/actions)\n\n## Installation\n\nAdd this line to your application’s Gemfile:\n\n```ruby\ngem \"anomaly_detection\"\n```\n\n## Getting Started\n\nDetect anomalies in a time series\n\n```ruby\nseries = {\n  Date.parse(\"2025-01-01\") =\u003e 100,\n  Date.parse(\"2025-01-02\") =\u003e 150,\n  Date.parse(\"2025-01-03\") =\u003e 136,\n  # ...\n}\n\nAnomalyDetection.detect(series, period: 7)\n```\n\nWorks great with [Groupdate](https://github.com/ankane/groupdate)\n\n```ruby\nseries = User.group_by_day(:created_at).count\nAnomalyDetection.detect(series, period: 7)\n```\n\nSeries can also be an array without times (the index is returned)\n\n```ruby\nseries = [100, 150, 136, ...]\nAnomalyDetection.detect(series, period: 7)\n```\n\n## Options\n\nPass options\n\n```ruby\nAnomalyDetection.detect(\n  series,\n  period: 7,            # number of observations in a single period\n  alpha: 0.05,          # level of statistical significance\n  max_anoms: 0.1,       # maximum number of anomalies as percent of data\n  direction: \"both\",    # pos, neg, or both\n  verbose: false        # show progress\n)\n```\n\n## Plotting\n\nAdd [Vega](https://github.com/ankane/vega) to your application’s Gemfile:\n\n```ruby\ngem \"vega\"\n```\n\nAnd use:\n\n```ruby\nAnomalyDetection.plot(series, anomalies)\n```\n\n## Credits\n\nThis library was ported from the [AnomalyDetection](https://github.com/twitter/AnomalyDetection) R package and is available under the same license. It uses [stl-cpp](https://github.com/ankane/stl-cpp) for seasonal-trend decomposition and [dist.h](https://github.com/ankane/dist.h) for the quantile function.\n\n## References\n\n- [Automatic Anomaly Detection in the Cloud Via Statistical Learning](https://arxiv.org/abs/1704.07706)\n\n## History\n\nView the [changelog](https://github.com/ankane/AnomalyDetection.rb/blob/master/CHANGELOG.md)\n\n## Contributing\n\nEveryone is encouraged to help improve this project. Here are a few ways you can help:\n\n- [Report bugs](https://github.com/ankane/AnomalyDetection.rb/issues)\n- Fix bugs and [submit pull requests](https://github.com/ankane/AnomalyDetection.rb/pulls)\n- Write, clarify, or fix documentation\n- Suggest or add new features\n\nTo get started with development:\n\n```sh\ngit clone https://github.com/ankane/AnomalyDetection.rb.git\ncd AnomalyDetection.rb\nbundle install\nbundle exec rake compile\nbundle exec rake test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankane%2Fanomalydetection.rb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fankane%2Fanomalydetection.rb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankane%2Fanomalydetection.rb/lists"}