异常检测学习笔记--Task01:异常检测介绍

1.目标要求

  • 了解异常检测基本概念
  • 了解异常检测基本方法

2 异常检测基本内容

2.1 异常检测应用场景

与预期行为差异较大的数据,例如,识别信用卡欺诈、工业生产异常、网络流量异常等问题。

2.2 异常的类别

点异常、上下文异常、群体异常

2.3 异常检测数据集、

常分为三种:

  • 统计型数据static data(文本、网络流)
  • 序列型数据sequential data(sensor data )
  • 空间型数据spatial data(图像、视频)

3.异常检测常用方法:

3.1传统方法

3.1.1基于统计学的方法

思想:学习生成一个拟合给定数据集的生成模型,识别该模型低概率区域中的对象,把他们当作异常点。

3.1.2 线性模型

PCA主成分分析。降维并最大程度保留原始数据特征。缓解高维灾难。

3.1.3 基于相似度的方法

适用范围:数据点聚集程度高、离群点较少
缺点:计算量大,不太适用于数据量大、高维度的数据
基于集群的检测:DBSCAN等聚类算法
基于距离的度量:k近邻算法
基于密度的度量:LOF算法

3.2 集成方法

将多个算法或多个基检测器输出结合使用。
常用方法:feature bagging, 孤立森林

3.3 机器学习

gbdt、xgboost分类
缺点:异常检测场景下数据标签不均衡
优点:构造不同特征

4.常用开源库

Scikit-Learn、pyod

4.1 开源库的安装

4.1.1 查看anaconda指令

打开anaconda prompt,输入conda help

conda help

接下来将会显示conda的指令及用法

usage: conda-script.py [-h] [-V] command ...

conda is a tool for managing and deploying applications, environments and packages.

Options:

positional arguments:
  command
    clean        Remove unused packages and caches.
    compare      Compare packages between conda environments.
    config       Modify configuration values in .condarc. This is modeled after the git config command. Writes to the
                 user .condarc file (C:\Users\Lenovo\.condarc) by default.
    create       Create a new conda environment from a list of specified packages.
    help         Displays a list of available conda commands and their help strings.
    info         Display information about current conda install.
    init         Initialize conda for shell interaction. [Experimental]
    install      Installs a list of packages into a specified conda environment.
    list         List linked packages in a conda environment.
    package      Low-level conda package utility. (EXPERIMENTAL)
    remove       Remove a list of packages from a specified conda environment.
    uninstall    Alias for conda remove.
    run          Run an executable in a conda environment. [Experimental]
    search       Search for packages and display associated information. The input is a MatchSpec, a query language
                 for conda packages. See examples below.
    update       Updates conda packages to the latest compatible version.
    upgrade      Alias for conda update.

optional arguments:
  -h, --help     Show this help message and exit.
  -V, --version  Show the conda version number and exit.

conda commands available from other packages:
  build
  content-trust
  convert
  debug
  develop
  env
  index
  inspect
  metapackage
  render
  repo
  server
  skeleton
  token
  verify
###4.1.2 使用anaconda安装scikit-learn

这里我们使用conda install来安装Scikit-learn开源机器学习库。

conda install -c anaconda scikit-learn

安装完成后,使用如下命令测试,若出现下述界面则安装成功

>>> import sklearn
>>>

4.1.2 使用anaconda安装pyod

pip install pyod

安装完成后,使用如下命令测试,若出现下述界面则安装成功

>>> import pyod
>>>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容