# banpei **Repository Path**: guobin1130/banpei ## Basic Information - **Project Name**: banpei - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2019-06-18 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## Banpei [![Build Status](https://travis-ci.org/tsurubee/banpei.svg?branch=master)](https://travis-ci.org/tsurubee/banpei) 异常检测类型: ![输入图片说明](https://images.gitee.com/uploads/images/2019/0606/183458_74653da7_2165307.png "屏幕截图.png") 对于单变量的时序数据可以有以下几种情况 1、数据无规律波动,但是正常稳定情况下,时序数据大致在一个稳定的区间内波动,通常可以设计一组不同等级的阈值,进行阈值的异常报警(基于统计); 2、数据长期波动幅度较大,但是正常情况下,短期内数据波动幅度较小,整体展现出较为平稳的上涨或者下降,这里对应的异常就是断层异常,是否在某个时刻数据陡增或者陡降(结合前后的变化); 3、数据有明显的规律性和周期性,通过学习周期变化、涨幅变化得到最终异常数据(基于预测); 异常检测方法: ![输入图片说明](https://images.gitee.com/uploads/images/2019/0606/183609_77702a16_2165307.png "屏幕截图.png") ![输入图片说明](https://images.gitee.com/uploads/images/2019/0606/184128_78b31a74_2165307.png "屏幕截图.png") 算法分两部分 #### Outlier detection 异常值检测 * Hotelling's theory (基于统计) ![输入图片说明](https://images.gitee.com/uploads/images/2019/0529/193356_70243d1d_2165307.png "屏幕截图.png") #### Change point detection 变点检测,其基本定义是在一个序列或过程中,当某个统计特性(分布类型、分布参数)在某时间点受系统性因素而非偶然因素影响发生变化,我们就称该时间点为变点。 * Singular spectrum transformation(sst) (基于主成分分析PCA) ![![输入图片说明](https://images.gitee.com/uploads/images/2019/0529/193233_5292c33d_2165307.png "屏幕截图.png")](https://images.gitee.com/uploads/images/2019/0529/193232_671e3a09_2165307.png "屏幕截图.png") Banpei is a Python package of the anomaly detection. Anomaly detection is a technique used to identify unusual patterns that do not conform to expected behavior. ## System Python 3.x (2.x is not supported) ## Installation Use the command: ```bash $ git clone https://github.com/tsurubee/banpei.git $ cd banpei $ pip install . ``` After installation, you can import banpei in Python. ``` $ python >>> import banpei ``` ## Usage #### Example *Singular spectrum transformation(sst)* ```python import banpei model = banpei.SST(w=50) results = model.detect(data) ``` The input 'data' must be one-dimensional array-like object containing a sequence of values. The output 'results' is Numpy array with the same size as input data. The graph below shows the change-point scoring calculated by sst for the periodic data. sst_example The data used is placed as '/tests/test_data/periodic_wave.csv'. You can read a CSV file using the following code. ```python import pandas as pd raw_data = pd.read_csv('./tests/test_data/periodic_wave.csv') data = raw_data['y'] ``` SST processing can be accelerated using the Lanczos method which is one of Krylov subspace methods by specifying `True` for the `is_lanczos` argument like below. ```python results = model.detect(data, is_lanczos=True) ``` ## Real-time monitoring with Bokeh Banpei is developed with the goal of constructing the environment of real-time abnormality monitoring. In order to achieve the goal, Banpei has the function corresponded to the streaming data. With the help of Bokeh, which is great visualization library, we can construct the simple monitoring tool. Here's a simple demonstration movie of change-point detection of the data trends. [![sst detection](https://img.youtube.com/vi/7_woubLAhXk/0.jpg)](https://www.youtube.com/watch?v=7_woubLAhXk) https://youtu.be/7_woubLAhXk The sample code how to construct real-time monitoring environment is placed in '/demo' folder. ## The implemented algorithm #### Outlier detection * Hotelling's theory #### Change point detection * Singular spectrum transformation(sst) ## License This project is licensed under the terms of the MIT license, see LICENSE.![输入图片说明](https://images.gitee.com/uploads/images/2019/0529/193331_90912ddd_2165307.png "在这里输入图片标题")