{"id":13415298,"url":"https://github.com/twitter/AnomalyDetection","last_synced_at":"2025-03-14T22:33:19.360Z","repository":{"id":24379232,"uuid":"27778839","full_name":"twitter/AnomalyDetection","owner":"twitter","description":"Anomaly Detection with R","archived":true,"fork":false,"pushed_at":"2019-08-30T19:49:16.000Z","size":1377,"stargazers_count":3530,"open_issues_count":71,"forks_count":776,"subscribers_count":330,"default_branch":"master","last_synced_at":"2024-04-14T06:36:00.475Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"R","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/twitter.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-09T17:46:24.000Z","updated_at":"2024-04-11T19:17:12.000Z","dependencies_parsed_at":"2022-07-12T16:07:48.991Z","dependency_job_id":null,"html_url":"https://github.com/twitter/AnomalyDetection","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twitter%2FAnomalyDetection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twitter%2FAnomalyDetection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twitter%2FAnomalyDetection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twitter%2FAnomalyDetection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/twitter","download_url":"https://codeload.github.com/twitter/AnomalyDetection/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243658057,"owners_count":20326459,"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-07-30T21:00:46.736Z","updated_at":"2025-03-14T22:33:19.353Z","avatar_url":"https://github.com/twitter.png","language":"R","funding_links":[],"categories":["异常检测包","R","Anomaly Detection Software","[R](#r)","Table of Contents","Machine Learning","工具箱与数据集","Tools and Algorithms"],"sub_categories":["3.2 时间序列异常检测"],"readme":"# AnomalyDetection R package\n\n[![Build Status](https://travis-ci.org/twitter/AnomalyDetection.png)](https://travis-ci.org/twitter/AnomalyDetection)\n[![Pending Pull-Requests](http://githubbadges.herokuapp.com/twitter/AnomalyDetection/pulls.svg?style=flat)](https://github.com/twitter/AnomalyDetection/pulls)\n[![Github Issues](http://githubbadges.herokuapp.com/twitter/AnomalyDetection/issues.svg)](https://github.com/twitter/AnomalyDetection/issues)\n\nAnomalyDetection is an open-source R package to detect anomalies which is\nrobust, from a statistical standpoint, in the presence of seasonality and an\nunderlying trend. The AnomalyDetection package can be used in wide variety of\ncontexts. For example, detecting anomalies in system metrics after a new\nsoftware release, user engagement post an A/B test, or for problems in\neconometrics, financial engineering, political and social sciences.\n\n## How the package works\n\nThe underlying algorithm – referred to as Seasonal Hybrid ESD (S-H-ESD) builds\nupon the Generalized ESD test for detecting anomalies. Note that S-H-ESD can\nbe used to detect both global as well as local anomalies. This is achieved by\nemploying time series decomposition and using robust statistical metrics, viz.,\nmedian together with ESD. In addition, for long time series (say, 6 months of\nminutely data), the algorithm employs piecewise approximation - this is rooted\nto the fact that trend extraction in the presence of anomalies in non-trivial -\nfor anomaly detection.\n\nBesides time series, the package can also be used to detect anomalies in a\nvector of numerical values. We have found this very useful as many times the\ncorresponding timestamps are not available. The package provides rich\nvisualization support. The user can specify the direction of anomalies, the\nwindow of interest (such as last day, last hour), enable/disable piecewise\napproximation; additionally, the x- and y-axis are annotated in a way to assist\nvisual data analysis.\n\n## How to get started\n\nInstall the R package using the following commands on the R console:\n\n```\ninstall.packages(\"devtools\")\ndevtools::install_github(\"twitter/AnomalyDetection\")\nlibrary(AnomalyDetection)\n```\n\nThe function AnomalyDetectionTs is called to detect one or more statistically\nsignificant anomalies in the input time series. The documentation of the\nfunction AnomalyDetectionTs, which can be seen by using the following command,\ndetails the input arguments and the output of the function AnomalyDetectionTs.\n\n```\nhelp(AnomalyDetectionTs)\n```\n\nThe function AnomalyDetectionVec is called to detect one or more statistically\nsignificant anomalies in a vector of observations. The documentation of the\nfunction AnomalyDetectionVec, which can be seen by using the following command,\ndetails the input arguments and the output of the function AnomalyDetectionVec.\n\n```\nhelp(AnomalyDetectionVec)\n```\n\n## A simple example\n\nTo get started, the user is recommended to use the example dataset which comes\nwith the packages. Execute the following commands:\n\n```\ndata(raw_data)\nres = AnomalyDetectionTs(raw_data, max_anoms=0.02, direction='both', plot=TRUE)\nres$plot\n```\n\n![Fig 1](https://github.com/twitter/AnomalyDetection/blob/master/figs/Fig1.png)\n\nFrom the plot, we observe that the input time series experiences both positive \nand negative anomalies. Furthermore, many of the anomalies in the time series\nare local anomalies within the bounds of the time series’ seasonality (hence,\ncannot be detected using the traditional approaches). The anomalies detected\nusing the proposed technique are annotated on the plot. In case the timestamps \nfor the plot above were not available, anomaly detection could then carried \nout using the AnomalyDetectionVec function; specifically, one can use the \nfollowing command:\n\n```\nAnomalyDetectionVec(raw_data[,2], max_anoms=0.02, period=1440, direction='both', only_last=FALSE, plot=TRUE)\n```\n\nOften, anomaly detection is carried out on a periodic basis. For instance, at\ntimes, one may be interested in determining whether there was any anomaly\nyesterday. To this end, we support a flag only_last whereby one can subset the\nanomalies that occurred during the last day or last hour. Execute the following \ncommand:\n\n```\nres = AnomalyDetectionTs(raw_data, max_anoms=0.02, direction='both', only_last=”day”, plot=TRUE)\nres$plot\n```\n\n![Fig 2](https://github.com/twitter/AnomalyDetection/blob/master/figs/Fig2.png)\n\nFrom the plot, we observe that only the anomalies that occurred during the last\nday have been annotated. Further, the prior six days are included to expose the\nseasonal nature of the time series but are put in the background as the window\nof prime interest is the last day.\n\nAnomaly detection for long duration time series can be carried out by setting\nthe longterm argument to T. \n\n## Copyright and License\nCopyright 2015 Twitter, Inc and other contributors\n\nLicensed under the GPLv3\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwitter%2FAnomalyDetection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftwitter%2FAnomalyDetection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwitter%2FAnomalyDetection/lists"}