PyOD简介
异常检测(anomaly detection),也叫异常分析(outlier analysis或者outlier detection)或者离群值检测,在工业上有非常广泛的应用场景:
金融业:从海量数据中找到“欺诈案例”,如信用卡反诈骗,识别虚假信贷
网络安全:从流量数据中找到“侵入者”,识别新的网络入侵模式
在线零售:从交易数据中发现“恶意买家”,比如恶意刷评等
生物基因:从生物数据中检测“病变”或“突变”
同时它可以被用于机器学习任务中的预处理(preprocessing),防止因为少量异常点存在而导致的训练或预测失败。换句话来说,异常检测就是从茫茫数据中找到那些“长得不一样”的数据。但检测异常过程一般都比较复杂,而且实际情况下数据一般都没有标签(label),我们并不知道哪些数据是异常点,所以一般很难直接用简单的监督学习。异常值检测还有很多困难,如极端的类别不平衡、多样的异常表达形式、复杂的异常原因分析等。
异常值不一定是坏事。 例如,如果在生物学中实验,一只老鼠没有死,而其他一切都死,那么理解为什么会非常有趣。这可能会带来新的科学发现。 因此,检测异常值非常重要。
Python Outlier Detection(PyOD)是一个Python异常检测工具库,除了支持Sklearn上支持的四种模型外,还额外提供了很多模型如:
传统异常检测方法:HBOS、PCA、ABOD和Feature Bagging等。
基于深度学习与神经网络的异常检测:自编码器(keras实现)
其主要亮点包括:
包括近20种常见的异常检测算法,比如经典的LOF/LOCI/ABOD以及最新的深度学习如对抗生成模型(GAN)和集成异常检测(outlier ensemble)
所有算法共享通用的API,方便快速调包,同时支持Python2和3。支持多种操作系统:windows,macOS和Linux。
代码经过了重重优化,大部分模型通过了并行与即时编译。使用JIT和并行化(parallelization)进行优化,加速算法运行及扩展性(scalability),可以处理大量数据
提供了详细的文档以及大量例子,方便快速上手
PyOD内置算法
PyOD工具包由三个主要功能组组成:
i) Individual Detection Algorithms:
Type
Abbr
Algorithm
Year
Ref
Linear Model
PCA
主成分分析(加权投影到特征向量超平面的距离之和)
2003
Linear Model
MCD
最小协方差行列式(使用马氏距离作为异常值分数)
1999
Linear Model
OCSVM
One-Class支持向量机
2001
Linear Model
LMDD
基于偏差的离群点检测Deviation-based Outlier Detection (LMDD)
1996
Proximity-Based
LOF
局部离群因子Local Outlier Factor
2000
Proximity-Based
COF
基于连通性的离群因子Connectivity-Based Outlier Factor
2002
Proximity-Based
CBLOF
基于聚类的局部离群因子Clustering-Based Local Outlier Factor
2003
Proximity-Based
LOCI
LOCI: Fast outlier detection using the local correlation integral
2003
Proximity-Based
HBOS
基于直方图的异常值得分Histogram-based Outlier Score
2012
Proximity-Based
kNN
k Nearest Neighbors (use the distance to the kth nearest neighbor as the outlier score)
2000
Proximity-Based
AvgKNN
Average kNN (use the average distance to k nearest neighbors as the outlier score)
2002
Proximity-Based
MedKNN
Median kNN (use the median distance to k nearest neighbors as the outlier score)
2002
Proximity-Based
SOD
子空间离群点检测Subspace Outlier Detection
2009
Probabilistic
ABOD
基于角度的离群点检测Angle-Based Outlier Detection
2008
Probabilistic
FastABOD
Fast Angle-Based Outlier Detection using approximation
2008
Probabilistic
SOS
随机离群点选择Stochastic Outlier Selection
2012
Outlier Ensembles
IForest
Isolation Forest
2008
Outlier Ensembles
Feature Bagging
2005
Outlier Ensembles
LSCP
并行孤立点群的局部选择性组合LSCP: Locally Selective Combination of Parallel Outlier Ensembles
2019
Outlier Ensembles
XGBOD
Extreme Boosting Based Outlier Detection (Supervised)
2018
Outlier Ensembles
LODA
Lightweight On-line Detector of Anomalies
2016
Neural Networks
AutoEncoder
Fully connected AutoEncoder (use reconstruction error as the outlier score)
[1] [Ch.3]
Neural Networks
VAE
Variational AutoEncoder (use reconstruction error as the outlier score)
2013
Neural Networks
SO_GAAL
Single-Objective Generative Adversarial Active Learning
2019
Neural Networks