CN107066613A - 一种基于相对密度的异常检测算法 - Google Patents
一种基于相对密度的异常检测算法 Download PDFInfo
- Publication number
- CN107066613A CN107066613A CN201710315738.0A CN201710315738A CN107066613A CN 107066613 A CN107066613 A CN 107066613A CN 201710315738 A CN201710315738 A CN 201710315738A CN 107066613 A CN107066613 A CN 107066613A
- Authority
- CN
- China
- Prior art keywords
- density
- point
- relative density
- detection algorithm
- outlier detection
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000013450 outlier detection Methods 0.000 title claims abstract description 21
- 230000005856 abnormality Effects 0.000 claims abstract description 19
- HUTDUHSNJYTCAR-UHFFFAOYSA-N ancymidol Chemical compound C1=CC(OC)=CC=C1C(O)(C=1C=NC=NC=1)C1CC1 HUTDUHSNJYTCAR-UHFFFAOYSA-N 0.000 claims abstract description 7
- 238000001514 detection method Methods 0.000 claims description 15
- 230000006870 function Effects 0.000 claims description 4
- 238000002474 experimental method Methods 0.000 claims description 2
- 238000010606 normalization Methods 0.000 claims 1
- 238000000034 method Methods 0.000 abstract description 23
- 238000007418 data mining Methods 0.000 abstract description 4
- 238000010801 machine learning Methods 0.000 abstract description 4
- 230000007547 defect Effects 0.000 abstract 1
- 230000002159 abnormal effect Effects 0.000 description 5
- 239000005433 ionosphere Substances 0.000 description 4
- 230000006793 arrhythmia Effects 0.000 description 2
- 206010003119 arrhythmia Diseases 0.000 description 2
- 235000013399 edible fruits Nutrition 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 239000011521 glass Substances 0.000 description 2
- 238000012360 testing method Methods 0.000 description 2
- 230000002547 anomalous effect Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000003247 decreasing effect Effects 0.000 description 1
- 230000002950 deficient Effects 0.000 description 1
- 238000003745 diagnosis Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
Landscapes
- Engineering & Computer Science (AREA)
- Databases & Information Systems (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本发明公开的一种基于相对密度的异常检测算法,属于机器学习和数据挖掘领域。本发明的异常检测算法基于最近邻思想,采取了局部相对密度的方法,异常点由数据点的密度和其近邻密度之间的差异而判定,对于一个给定的数据点,其与近邻之间的相对密度差异越大,则该数据点的异常性越大。同传统的基于密度的方式相比,相对密度方法更具准确性,不仅能够解决基于距离的方法无法检测局部异常的问题,而且能够克服基于密度方法对稀疏数据失效的缺陷。对于不同的数据能够检测出不同的异常类型的点。
Description
技术领域
本发明涉及数据挖掘和机器学习技术领域,具体是基于相对密度的异常检测算法。
背景技术
异常检测在数据挖掘和机器学习领域中是非常重要的任务。异常检测主要是在大量复杂的数据集中挖掘稀少的模式。在实际应用中异常模式所含有的信息往往比正常模式所含有的信息更加重要,例如在医疗诊断中挖掘出癌症病症(稀少模式)比正常信息要有用。异常检测技术广泛的应用于各种领域,例如网络流量入侵,信用卡检测,医疗健康检测等。
机器学习和数据挖掘已经定义了许多异常值检测方法,例如基于分布[1],基于距离[2][3],基于密度[4],基于聚类[5][6][7][8]。基于分布的异常检测需要先验的知道数据服从某种分布,然而在现实世界中很难得到数据的真实分布。[2]提出一种基于距离的异常检测方法,把数据点到其k-th近邻的距离作为该点的异常性。然而这种方法只能够检测到全局异常,对于局部异常的检测就会失效。[4]提出一种基于密度的异常检测,为一个数据点分配异常因子根据他所围绕的近邻。异常因子反映了一个数据点与其近邻的接近程度。这种方法是很好的异常检测方法,但是在稀疏的数据集上有一定的缺陷性。[3]提出了LDOF的方法是用来检测稀疏数据集中的异常点。基于聚类的思想是异常点往往出现在小的簇中。首先把数据集进行聚类,给定一个阈值,如果簇中的点的个数小于所给的阈值则定义为异常。本发明提出了一种相对密度的方法,本方法利用数据点的近邻密度与该数据点密度的比值来衡量数据的异常性。该方法能够检测到局部异常,并且克服了在稀疏密度情况下,基于密度方法效果减弱的问题。本方法对于异常点的检测准确率更高。
参考文献:
[1]Barnett V,Lewis T.Outliers in statistical data[M].Wiley,1974.
[2]Knox E M,Ng R T.Algorithms for mining distancebased outliers inlarge datasets[C]//Proceedings of the International Conference on Very LargeData Bases.1998:392-403.
[3]Zhang K,Hutter M,Jin H.A New Local Distance-Based OutlierDetection Approach for Scattered Real-World Data[C]//Pacific-Asia Conferenceon Advances in Knowledge Discovery and Data Mining.Springer-Verlag,2009:813-822.
[4]Breunig M M.LOF:identifying density-based local outliers[C]//ACMSIGMOD International Conference on Management of Data,May 16-18,2000,Dallas,Texas,Usa.CiteSeer,2000:93-104.
[5]Ester M,Kriegel H P,Sander J,et al.A density-based algorithm fordiscovering clusters in large spatial databases with noise[C]//Kdd.1996,96(34):226-231.
[6]Chawla S,Gionis A.k-means-:A unified approach to clustering andoutlier detection[C]//Proceedings of the 2013SIAM International Conference onData Mining.Society for Industrial and Applied Mathematics,2013:189-197.
[7]Huang J,Zhu Q,Yang L,et al.A Novel Outlier Cluster DetectionAlgorithm without Top-n Parameter[J].Knowledge-Based Systems,2017.
[8]Lucic M,Bachem O,Krause A.Linear-Time Outlier Detection viaSensitivity[J].arXiv preprint arXiv:1605.00519,2016.
发明内容
本发明要解决的问题是提供一种基于相对密度的异常检测算法,该算法采用基于相对密度的方式,假如数据点的密度与其近邻之间的密度的差异性较大,则该数据点的异常性高,在本方法中我们使用的是数据点的近邻密度与该点密度的比值来衡量该点的异常性。该比值越大则其异常性越高。
如图1所示,本发明公开的基于相对密度的异常检测算法,包括以下步骤:
步骤1)确定算法输入变量,包括待检测的无标记样本集D,最近邻的个数k,根据先验知识获得的异常点的个数n;
步骤2)将数据集D归一化,使得每个属性的取值在[0,1]之间,归一化的数据集记为D′;
步骤3)数据D′中给定的样本点p,根据距离函数dist(),获取点p的k个最近邻Nk(p);
步骤4)计算点p到Nk(p)中所有的点的平均距离则根据distknn(p)可以计算点p的密度density(p)=1/distknn(p);
步骤5)对于集合Nk(p)中的每一个数据点o∈Nk(p),分别计算其则可以计算点p的近邻密度
步骤6)计算点p的相对密度Rdensity(p)=nn_density(p)/density(p);
步骤7)数据集D′中的所有的样本都计算其Rdensity,可得到一个Rdensities[]数组;
步骤8)将Rdensities[]中的元素按照降序排列得到一个sorted_Rdensities[]数组;
步骤8)选取sorted_Rdensities[]中top-n个样本将其定义为异常点。
进一步,所述步骤1)中,k的选取对预测有一定的影响,我们这里k从[50,200]随机取值。
本发明的有益效果是:本发明基于相对密度的异常检测算法,采用数据点的密度与其近邻密度之间的差异性来衡量该数据点的异常性,同传统的异常检测算法相比,基于相对密度的异常检测算法具有更高的准确性和鲁棒性,本方法不仅能检测到全局异常,还能够检测到局部异常,因此能够满足不同类型数据和异常的要求。本发明的异常检测算法解决了现有异常检测算法识别准确率不高的问题,保证了异常识别的高准确度。
附图说明
图1为本发明基于相对密度的异常检测流程图。
具体实施方式
下面结合附图,对本发明提出的一种基于相对密度的异常检测算法进行详细说明。
如图1所示,本发明的基于相对密度的异常检测算法,包括以下步骤:
步骤1)确定算法输入变量,包括待检测的无标记样本集D,最近邻的个数k,k从[50,200]随机选择,根据先验知识获得的异常点的个数n;
步骤2)数据D中给定的样本点p,根据距离函数dist(),该距离函数为欧式距离,获取点p的k个最近邻Nk(p);
步骤3)计算点p到Nk(p)中所有的点的平均距离distknn(p),则根据distknn(p)可以计算点p的密度density(p);
步骤4)对于集合Nk(p)中的每一个数据点o∈Nk(p),分别计算其distknn(o),则可以计算点p的近邻密度nn_density(p);
步骤5)计算点p的相对密度Rdensity(p);
步骤6)数据集D中的所有的样本都计算其Rdensity,可得到一个Rdensities[]数组;
步骤7)将Rdensities[]中的元素按照降序排列得到一个sorted_Rdensities[]数组;
步骤8)选取sorted_Rdensities[]中top-n个样本将其定义为异常点。
以下详细地描述本发明对UCI数据库中6组数据和一组人工合成的数据的测试结果同其他异常检测方法相比准确性的改进。本发明提出的异常检测与目前最为流行的LOF和LDOF进行了比较。因为原始UCI数据库中数据存在标签,本实施例中,我们人为的将数据标签去除。本实例中,异常检测算法的性能使用AUC和Recall来衡量。AUC和Recall的值越高则算法的性能越好。
表1-数据集
数据集 | 样本数(m) | 异常个数(n) | 维数(d) |
Arrhythmia | 420 | 183 | 277 |
Ionosphere | 351 | 126 | 34 |
Pim | 768 | 268 | 8 |
Wdbc | 569 | 212 | 30 |
Glass | 214 | 68 | 10 |
Handwritten | 1593 | 65 | 255 |
Synth | 248 | 6 | 2 |
算法中的参数设置如下:对于LOF和LDOF中的参数k的选取,我们使用的是该算法作者常用的或者是建议的取值。LOF中k=5,LDOF中k应该大于等于其维数[3][8],在本发明中我们取k为数据的维数。本发明中参数k从[50,200]随机取值,重复十次上述步骤,最终结果取平均值。我们的方法定义为RDOF(Relative Density-Based Outlier Factor)。
表2-三种异常检测方法的AUC值,结果如下。加粗的为最优值
LOF | LDOF | RDOF | |
Arrhythmia | 0.7082 | 0.7059 | 0.7407 |
Ionosphere | 0.8353 | 0.8709 | 0.8798 |
Pim | 0.5768 | 0.5601 | 0.6273 |
Wdbc | 0.5389 | 0.5290 | 0.5644 |
Glass | 0.5487 | 0.5980 | 0.7653 |
Handwritten | 0.5365 | 0.5625 | 0.5542 |
Synth | 1.0000 | 0.8981 | 1.0000 |
Average | 0.7768 | 0.7492 | 0.7889 |
表2-三种异常检测方法的Recall值,结果如下。加粗的为最优值
为了排除k对实验结果的影响,我们取k=5、20、30、50、100、200,在数据集Ionosphere上比较各个算法。
表3-在数据集Ionosphsre上,不同的k取值下,三种异常检测方法的AUC值
LOF | LDOF | RDOF | |
5 | 0.83527 | 0.7136 | 0.8220 |
20 | 0.8643 | 0.8521 | 0.8615 |
30 | 0.8892 | 0.8655 | 0.8711 |
50 | 0.8572 | 0.8799 | 0.8869 |
100 | 0.8572 | 0.8766 | 0.8493 |
200 | 0.7428 | 0.8525 | 0.8624 |
Average | 0.841 | 0.850 | 0.8624 |
以上表2中显示,在实验用的7个数据上,本发明提出的算法稳定的优于传统的两种算法。
根据表3中显示,在数据集Ionosphere上基于k取值5,20,30,50,100,200的情况下,最终结果取平均值,本发明提出的算法略优于LOF算法和LDOF算法。
综上所述,以上实施例仅用以说明本发明的技术方案,并非用于限定本发明的保护范围。凡在本发明的精神和原则之内,所做的任何修改、等同替换、改进等,其均应涵盖在本发明的权利要求范围当中。
Claims (7)
1.一种基于相对密度的异常检测算法,其特征在于,包括以下步骤:
步骤1)确定算法输入变量,包括待检测的无标记样本集D,最近邻的个数k,根据先验知识获得的异常点的个数n;
步骤2)将数据集D归一化,使得每个属性的取值在[0,1]之间,归一化的数据集记为D′;
步骤3)数据D中给定的样本点p,根据距离函数dist(),获取点p的k个最近邻Nk(p);
步骤4)计算点p到Nk(p)中所有的点的平均距离distknn(p),则根据distknn(p)可以计算点p的密度density(p);
步骤5)对于集合Nk(p)中的每一个数据点o∈Nk(p),分别计算其distknn(o),则可以计算点p的近邻密度nn_density(p);
步骤6)计算点p的相对密度Rdensity(p);
步骤7)数据集D′中的所有的样本都计算其Rdensity,可得到一个Rdensities[]数组;
步骤8)将Rdensities[]中的元素按照降序排列得到一个sorted_Rdensities[]数组;
步骤9)选取sorted_Rdensities[]中top-n个样本将其定义为异常点。
2.根据权利要求1所述的基于相对密度的异常检测算法,其特征在于:所述步骤1)中,k的取值影响检测算法的性能,然而k的值确定非常困难。由于是无监督学习,我们无法通过验证来确定k的值。因此在本发明中k从[50,200]随机取值,重复试验10次,取其平均值作为最终实验结果,这样减少算法对参数k取值的敏感度。
3.根据权利要求1所述的基于相对密度的异常检测算法,其特征在于:所述步骤2)中,所选取的归一化方式为其中xi为样本点的第i个属性,min和max分别为该属性的最小值和最大值。
4.根据权利要求1所述的基于相对密度的异常检测算法,其特征在于:所述步骤3)中,所选取的距离度量为欧式距离。
5.根据权利要求1所述的基于基于相对密度的异常检测算法,其特征在于:所述步骤4)中,所述点p的密度为density(p)=1/distknn(p)。
6.根据权利要求1所述的基于相对密度的异常检测算法,其特征在于:所述步骤5)中,点p的近邻密度为
7.根据权利要求1所述的基于相对密度的异常检测算法,其特征在于:所述步骤6)中,点p的异常性用相对密度来表示,记为Rdensity(p),Rdensity(p)=nn_density(p)/density(p)。
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710315738.0A CN107066613A (zh) | 2017-05-02 | 2017-05-02 | 一种基于相对密度的异常检测算法 |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710315738.0A CN107066613A (zh) | 2017-05-02 | 2017-05-02 | 一种基于相对密度的异常检测算法 |
Publications (1)
Publication Number | Publication Date |
---|---|
CN107066613A true CN107066613A (zh) | 2017-08-18 |
Family
ID=59597559
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710315738.0A Pending CN107066613A (zh) | 2017-05-02 | 2017-05-02 | 一种基于相对密度的异常检测算法 |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107066613A (zh) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109670973A (zh) * | 2018-12-13 | 2019-04-23 | 平安医疗健康管理股份有限公司 | 社保违规检测方法、装置、设备及计算机存储介质 |
CN109981630A (zh) * | 2019-03-19 | 2019-07-05 | 齐鲁工业大学 | 基于卡方检验和ldof算法的入侵检测方法及系统 |
CN114943865A (zh) * | 2022-06-17 | 2022-08-26 | 平安科技(深圳)有限公司 | 基于人工智能的目标检测样本优化方法及相关设备 |
-
2017
- 2017-05-02 CN CN201710315738.0A patent/CN107066613A/zh active Pending
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109670973A (zh) * | 2018-12-13 | 2019-04-23 | 平安医疗健康管理股份有限公司 | 社保违规检测方法、装置、设备及计算机存储介质 |
CN109981630A (zh) * | 2019-03-19 | 2019-07-05 | 齐鲁工业大学 | 基于卡方检验和ldof算法的入侵检测方法及系统 |
CN109981630B (zh) * | 2019-03-19 | 2022-03-29 | 齐鲁工业大学 | 基于卡方检验和ldof算法的入侵检测方法及系统 |
CN114943865A (zh) * | 2022-06-17 | 2022-08-26 | 平安科技(深圳)有限公司 | 基于人工智能的目标检测样本优化方法及相关设备 |
CN114943865B (zh) * | 2022-06-17 | 2024-05-07 | 平安科技(深圳)有限公司 | 基于人工智能的目标检测样本优化方法及相关设备 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Mandhare et al. | A comparative study of cluster based outlier detection, distance based outlier detection and density based outlier detection techniques | |
Barbará et al. | Detecting outliers using transduction and statistical testing | |
Fan et al. | Robust deep auto-encoding Gaussian process regression for unsupervised anomaly detection | |
Muller et al. | OutRank: ranking outliers in high dimensional data | |
CN111860692B (zh) | 一种基于K-mediod的物联网环境下的异常数据检测方法 | |
Wibisono et al. | Multivariate weather anomaly detection using DBSCAN clustering algorithm | |
CN104539484A (zh) | 一种动态评估网络连接可信度的方法及系统 | |
CN107066613A (zh) | 一种基于相对密度的异常检测算法 | |
CN109947815B (zh) | 一种基于离群点算法的窃电辨识方法 | |
CN113537321B (zh) | 一种基于孤立森林和x均值的网络流量异常检测方法 | |
Modi et al. | Outlier analysis approaches in data mining | |
CN110149347A (zh) | 利用拐点半径实现动态自适应聚类的网络入侵检测方法 | |
Kim et al. | A generalised uncertain decision tree for defect classification of multiple wafer maps | |
Shi et al. | An improved agglomerative hierarchical clustering anomaly detection method for scientific data | |
Cai et al. | An efficient outlier detection approach on weighted data stream based on minimal rare pattern mining | |
Sui et al. | Dynamic clustering scheme for evolving data streams based on improved STRAP | |
Su et al. | N2DLOF: A new local density-based outlier detection approach for scattered data | |
CN107944502A (zh) | 一种基于随机哈希的异常检测算法 | |
Cao et al. | Data-defect inspection with kernel-neighbor-density-change outlier factor | |
Rahman et al. | An efficient approach for selecting initial centroid and outlier detection of data clustering | |
Jia et al. | Anomaly detection method using center offset measurement based on leverage principle | |
Koo et al. | A unified defect pattern analysis of wafer maps using density-based clustering | |
Sharify et al. | Improved lof algorithm using random point | |
CN110278189B (zh) | 一种基于网络流量特征权重图谱的入侵检测方法 | |
Chen et al. | Fusing multi-scale fuzzy information to detect outliers |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
WD01 | Invention patent application deemed withdrawn after publication | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20170818 |