{"id":19836496,"url":"https://github.com/guobinhit/archimedes","last_synced_at":"2026-05-11T01:16:28.388Z","repository":{"id":39947913,"uuid":"230179098","full_name":"guobinhit/archimedes","owner":"guobinhit","description":"♨️ An outlier detection service applied to time series.","archived":false,"fork":false,"pushed_at":"2022-07-11T12:24:04.000Z","size":83,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-11T10:49:05.166Z","etag":null,"topics":["algorithm","anomaly","dbscan","detection","lof","outlier","time-series","z-score"],"latest_commit_sha":null,"homepage":"https://guobinhit.github.io/archimedes/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/guobinhit.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":"2019-12-26T02:12:59.000Z","updated_at":"2022-07-11T12:24:00.000Z","dependencies_parsed_at":"2022-08-25T09:11:24.357Z","dependency_job_id":null,"html_url":"https://github.com/guobinhit/archimedes","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guobinhit%2Farchimedes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guobinhit%2Farchimedes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guobinhit%2Farchimedes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guobinhit%2Farchimedes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/guobinhit","download_url":"https://codeload.github.com/guobinhit/archimedes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241202186,"owners_count":19926564,"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":["algorithm","anomaly","dbscan","detection","lof","outlier","time-series","z-score"],"created_at":"2024-11-12T12:11:31.257Z","updated_at":"2026-05-11T01:16:28.355Z","avatar_url":"https://github.com/guobinhit.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# archimedes\n\n![author](https://img.shields.io/badge/author-chariesgavin-blueviolet.svg)![last commit](https://img.shields.io/github/last-commit/guobinhit/archimedes.svg)![issues](https://img.shields.io/github/issues/guobinhit/archimedes.svg)![stars](https://img.shields.io/github/stars/guobinhit/archimedes.svg)![forks](\thttps://img.shields.io/github/forks/guobinhit/archimedes.svg)![license](https://img.shields.io/github/license/guobinhit/archimedes.svg)\n\n\u003e **语言**：中文 | [英文](https://github.com/guobinhit/archimedes/blob/master/README_ENGLISH.md)\n\n## 索引\n\n- [算法概述](#算法概述)\n  - [DBSCAN](#DBSCAN)\n  - [LOF](#LOF)\n  - [STCR](#STCR)\n  - [3-SIGMA](#3-SIGMA)\n  - [Z-SCORE](#Z-SCORE)\n  - [QUARTILE](#QUARTILE)\n- [使用示例](#使用示例)\n  - [异常检测](#异常检测)\n  - [趋势预测](#趋势预测)\n\n### 算法概述\n\n#### DBSCAN\n\nDBSCAN 是 Density-Based Spatial Clustering of Applications with Noise 的简写，是一个比较有代表性的基于密度的聚类算法。与划分和层次聚类方法不同，它将簇定义为密度相连的点的最大集合，能够把具有足够高密度的区域划分为簇，并可在噪声的空间数据库中发现任意形状的聚类。如果某个点不属于任意簇，则被视为噪声点，也就是异常点。\n\n#### LOF\n\nLOF 是 Local Outlier Factor 的简写，也称为局部异常因子算法，LOF 通过计算一个数值分来反映一个样本的异常程度。这个数值的大致意思是，一个样本点周围的样本点所处位置的平均密度比上该样本点所在位置的密度，比值越大于 1，则该点所在位置的密度越小于其周围样本所在位置的密度，这个点就越有可能是异常点。\n\n#### STCR\n\nSTCR 是 Short Term Chain Ratio 的缩写，也称为短期环比法，对于时间序列（是指将同一统计指标的数值按其发生的时间先后顺序排列而成的数列）来说，T 时刻的数值对于 T−1 时刻有很强的依赖性，比如流量在 8:00 很多，在 8:01 时刻的概率是很大的，但是如果 07:01 时刻对于 8:01 时刻影响不是很大。\n\n#### 3-SIGMA\n\n3-SIGMA法，也称为拉依达准则，它是先假设一组检测数据只含有随机误差，对其进行计算处理得到标准偏差，按一定概率确定一个区间，认为凡超过这个区间的误差，就不属于随机误差而是粗大误差。一般认为，数值分布几乎全部集中在 (μ-3σ,μ+3σ) 区间内，超出这个范围的可能性仅占不到 0.3%，其中 μ 是均值，σ 是标准差。进而认为，当数据分布区间超过这个区间时，即为异常数据，也就是异常点。\n\n#### Z-SCORE\n\nZ-SCORE 法，即 Z 分数法，也称为标准分数法，是指一个数与平均数的差再除以标准差的过程。在统计学中，标准分数是一个观测或数据点的值高于被观测值或测量值的平均值的标准偏差的符号数。该方法假定数据是高斯分布的，异常点是分布尾部的数据点，因此远离数据的平均值。距离的远近取决于使用公式计算的归一化数据点设定的阈值，根据经验，阈值一般设置为 2.5、3.0 和 3.5，本项目使用的 Z 分数法设置 3.5 为阈值。\n\n#### QUARTILE\n\nQUARTILE 法，即四分位法，也称为箱型图，是指在统计学中把所有数值由小到大排列并分成四等份，其中每部分包含 25% 的数据，处在 25% 位置上的数值又称为上四分位数，处在 75% 位置上的数值又称为下四分位数，凡处于上下四分数之外的点，即视为异常点。\n\n### 使用示例\n\n#### 异常检测\n\n首先，引入本项目 jar 包，创建`OutlierDetectionService`实例：\n\n```java\nOutlierDetectionService odService = new OutlierDetectionService();\n```\n\n然后，调用`OutlierDetectionService`的`outlierDetect()`方法。当然，在调用`outlierDetect()`方法之前，我们需要先创建该方法的参数对象`OutlierDetectionParam`，该对象含有三个参数，分别为：\n\n- `algorithmType`，表示算法类型，为`DetectionAlgorithmTypeEnum`枚举类型，必填项；\n- `orderType`，表示排序类型，为`OrderTypeEnum`枚举类型，用于对原始数据按时间排序，选填项；\n- `dataMapList`，表示数据集，即待处理的数据列表，非空且数量必须大于0，必填项。\n\n```java\n// 格式化数据集\nList\u003cMap\u003cString, Object\u003e\u003e dataMapList = new ArrayList\u003c\u003e();\n\n// 组装参数\nOutlierDetectionParam odParam = new OutlierDetectionParam();\n// 使用四分位法\nodParam.setAlgorithmType(DetectionAlgorithmTypeEnum.QUARTILE);\n// 将数据集按时间升序排序\nodParam.setOrderType(OrderTypeEnum.ASC);\n// 填充数据集\nodParam.setDataMapList(dataMapList);\n\n// 实例化异常点探测服务类，调用探测方法\nOutlierDetectionService odService = new OutlierDetectionService();\nOutlierDetectionResult odResult = odService.outlierDetect(odParam);\n```\n\n其中，我们需要特别注意`dataMapList`参数，其数据格式为`List\u003cMap\u003cString, Object\u003e\u003e`，且`Map\u003cString, Object\u003e`的键只能为下面两个字符串：\n\n- `value`，表示数值，必填项；\n- `date`，表示数值对应的时间，当`orderType`参数为空时，此项参数可不填，即表示不按时间排序。\n\n探测的结果对象为`OutlierDetectionResult`，其包含两个字段，分别为：\n\n- `dataMapList`，表示数据集，如果没有传`orderType`参数，则为原数据集，否则为排序后的数据集；\n- `outlierIndexList`，表示异常点的索引列表，即异常点的位置。\n\n#### 趋势预测\n\n- 待完善","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguobinhit%2Farchimedes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguobinhit%2Farchimedes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguobinhit%2Farchimedes/lists"}