{"id":13878401,"url":"https://github.com/ankane/anomaly","last_synced_at":"2025-11-17T14:16:10.161Z","repository":{"id":2024318,"uuid":"2960493","full_name":"ankane/anomaly","owner":"ankane","description":"Easy-to-use anomaly detection for Ruby","archived":false,"fork":false,"pushed_at":"2025-04-20T09:58:19.000Z","size":63,"stargazers_count":106,"open_issues_count":0,"forks_count":5,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-10-19T22:24:57.693Z","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":"mit","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,"zenodo":null}},"created_at":"2011-12-11T22:27:48.000Z","updated_at":"2025-10-10T17:21:14.000Z","dependencies_parsed_at":"2024-07-27T05:21:21.651Z","dependency_job_id":"935b1554-ca33-48c8-aab3-465b07082689","html_url":"https://github.com/ankane/anomaly","commit_stats":{"total_commits":86,"total_committers":5,"mean_commits":17.2,"dds":0.5813953488372092,"last_synced_commit":"31af4b4cb36993f21f973e1fd97b01aae3b8b561"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/ankane/anomaly","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Fanomaly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Fanomaly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Fanomaly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Fanomaly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ankane","download_url":"https://codeload.github.com/ankane/anomaly/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Fanomaly/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284894629,"owners_count":27080739,"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","status":"online","status_checked_at":"2025-11-17T02:00:06.431Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-08-06T08:01:48.543Z","updated_at":"2025-11-17T14:16:10.144Z","avatar_url":"https://github.com/ankane.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# Anomaly\n\nEasy-to-use anomaly detection for Ruby\n\n[![Build Status](https://github.com/ankane/anomaly/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/anomaly/actions)\n\n## Installation\n\nAdd this line to your application’s Gemfile:\n\n```ruby\ngem \"anomaly\"\n```\n\n## Getting Started\n\nSay 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:\n\n```ruby\n# [temperature(°F), humidity(%), pressure(in), sunny?(y=0, n=1)]\nweather_data = [\n  [85, 68, 10.4, 0],\n  [88, 62, 12.1, 0],\n  [86, 64, 13.6, 0],\n  [88, 90, 11.1, 1],\n  ...\n]\n```\n\nThe 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 ε.\n\nTrain the detector\n\n```ruby\ndetector = Anomaly::Detector.new(weather_data)\n```\n\nTest for anomalies\n\n```ruby\n# 85°F, 42% humidity, 12.3 in. pressure\ndetector.anomaly?([85, 42, 12.3])\n```\n\nAnomaly automatically finds the best value for ε, which you can access with:\n\n```ruby\ndetector.eps\n```\n\nIf you already know you want ε = 0.01, initialize the detector with:\n\n```ruby\ndetector = Anomaly::Detector.new(weather_data, eps: 0.01)\n```\n\n## Persistence\n\nYou can easily persist the detector to a file or database - it’s very tiny.\n\n```ruby\nbin = Marshal.dump(detector)\nFile.binwrite(\"detector.bin\", bin)\n```\n\nThen read it later:\n\n```ruby\nbin = File.binread(\"detector.bin\")\ndetector = Marshal.load(bin)\n```\n\n## Related Projects\n\n- [AnomalyDetection.rb](https://github.com/ankane/AnomalyDetection.rb) - Time series anomaly detection for Ruby\n- [Prophet.rb](https://github.com/ankane/prophet-ruby) - Time series forecasting (and anomaly detection) for Ruby\n- [IsoTree](https://github.com/ankane/isotree-ruby) - Outlier/anomaly detection for Ruby using Isolation Forest\n- [OutlierTree](https://github.com/ankane/outliertree-ruby) - Explainable outlier/anomaly detection for Ruby\n- [MIDAS](https://github.com/ankane/midas-ruby) - Edge stream anomaly detection for Ruby\n- [Random Cut Forest](https://github.com/ankane/random-cut-forest-ruby) - Random Cut Forest anomaly detection for Ruby\n- [Trend](https://github.com/ankane/trend-ruby) - Anomaly detection and forecasting for Ruby\n\n## Credits\n\nA special thanks to [Andrew Ng](https://www.coursera.org/learn/machine-learning).\n\n## History\n\nView the [changelog](https://github.com/ankane/anomaly/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/anomaly/issues)\n- Fix bugs and [submit pull requests](https://github.com/ankane/anomaly/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/anomaly.git\ncd anomaly\nbundle install\nbundle exec rake spec\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankane%2Fanomaly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fankane%2Fanomaly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankane%2Fanomaly/lists"}