demo:

from pyculiarity import detect_ts
import matplotlib.pyplot as plt
import pandas as pd
import matplotlib
matplotlib.style.use('ggplot') __author__ = 'willmcginnis' if __name__ == '__main__':
# first run the models
twitter_example_data = pd.read_csv('./raw_data.csv', usecols=['timestamp', 'count'])
results = detect_ts(twitter_example_data, max_anoms=0.05, alpha=0.001, direction='both', only_last=None) # format the twitter data nicely
twitter_example_data['timestamp'] = pd.to_datetime(twitter_example_data['timestamp'])
twitter_example_data.set_index('timestamp', drop=True) # make a nice plot
f, ax = plt.subplots(2, 1, sharex=True)
ax[0].plot(twitter_example_data['timestamp'], twitter_example_data['value'], 'b')
ax[0].plot(results['anoms'].index, results['anoms']['anoms'], 'ro')
ax[0].set_title('Detected Anomalies')
ax[1].set_xlabel('Time Stamp')
ax[0].set_ylabel('Count')
ax[1].plot(results['anoms'].index, results['anoms']['anoms'], 'b')
ax[1].set_ylabel('Anomaly Magnitude')
plt.show()

demo2代码如下:

from matplotlib import pyplot as plt
from pyculiarity import detect_ts
import pandas as pd
import numpy as np twitter_example_data = pd.read_csv('raw_data.csv',
usecols=['timestamp', 'count']) plt.plot(range(0, len(twitter_example_data)), twitter_example_data['count'], "k.", label='points')
results = detect_ts(twitter_example_data,
max_anoms=0.02,
direction='both')
print(results['anoms'][0:10])
print(results['anoms'][-10:])
print(len(results['anoms'])) for timestamp, anomal_val in zip(results['anoms']['timestamp'], results['anoms']['anoms']):
print(timestamp, anomal_val)
index_list = np.where(twitter_example_data["timestamp"] == timestamp)
assert len(index_list) == 1
plt.plot([index_list[0]], anomal_val, "rX", label='abnormal points')
plt.show()

效果图:

原始数据图:

红色为检测出来的异常点:

pyculiarity 时间序列(异常流量)异常检测初探——感觉还可以,和Facebook的fbprophet本质上一样的更多相关文章

  1. 思科安全:加密流量威胁检测、加密流量威胁和恶意软件检测、识别无线干扰或威胁、Talos 情报源可加强对已知和新型威胁的防御、分布式安全异常检测

    思科DNA竞品比较工具 您的网络能够驱动数字化转型吗? 根据IDC调查,45%的受调研公司计划在未来两年内做好网络数字化的准备.查看数字化网络带来的结果和商业价值. 下载报告 思科 HPE 华为 Ar ...

  2. #研发解决方案#基于Apriori算法的Nginx+Lua+ELK异常流量拦截方案

    郑昀 基于杨海波的设计文档 创建于2015/8/13 最后更新于2015/8/25 关键词:异常流量.rate limiting.Nginx.Apriori.频繁项集.先验算法.Lua.ELK 本文档 ...

  3. 基于Apriori算法的Nginx+Lua+ELK异常流量拦截方案 郑昀 基于杨海波的设计文档(转)

    郑昀 基于杨海波的设计文档 创建于2015/8/13 最后更新于2015/8/25 关键词:异常流量.rate limiting.Nginx.Apriori.频繁项集.先验算法.Lua.ELK 本文档 ...

  4. web异常流量定位:iftop+tcpdump+wireshark

    一个简单的运维小经验. 场景:web服务器出现异常流量,web集群内部交互出现大流量,需要定位具体的http请求,以便解决问题. 目的:找出产生大流量的具体http请求. 工具:        ift ...

  5. JAVA可检测异常和非检测异常

    Java的可检测异常和非检测异常泾渭分明.可检测异常经编译器验证,对于声明抛出异常的任何方法,编译器将强制执行处理或声明规则. 非检测异常不遵循处理或声明规则.在产生此类异常时,不一定非要采取任何适当 ...

  6. alluxio网络流量异常分析【转】

    1. 介绍 2. 准备工作 2.1 tcpdump 2.2 winshark 2.3 安装iftop 2.4 alluxio网络通信相关的端口 3.iftop 锁定消耗流量最大的端口 4. dump数 ...

  7. 一篇不错的讲解Java异常的文章(转载)----感觉很不错,读了以后很有启发

    六种异常处理的陋习 你觉得自己是一个Java专家吗?是否肯定自己已经全面掌握了Java的异常处理机制?在下面这段代码中,你能够迅速找出异常处理的六个问题吗? OutputStreamWriter ou ...

  8. DataPipeline王睿:业务异常实时自动化检测 — 基于人工智能的系统实战

    大家好,先自我介绍一下,我是王睿.之前在Facebook/Instagram担任AI技术负责人,现在DataPipeline任Head of AI,负责研发企业级业务异常检测产品,旨在帮助企业一站式解 ...

  9. 大数据DDos检测——DDos攻击本质上是时间序列数据,t+1时刻的数据特点和t时刻强相关,因此用HMM或者CRF来做检测是必然! 和一个句子的分词算法CRF没有区别!

    DDos攻击本质上是时间序列数据,t+1时刻的数据特点和t时刻强相关,因此用HMM或者CRF来做检测是必然!——和一个句子的分词算法CRF没有区别!注:传统DDos检测直接基于IP数据发送流量来识别, ...

随机推荐

  1. CentOS7.3防火墙firewalld简单配置

    今天安装了centos7.3, 想用iptables的save功能保存规则的时候发现跟rhel不一样了,  后来度娘说centos用的是firewalld而不是iptables了, 平时工作都是用re ...

  2. 20145327 《网络对抗》Web安全基础实践

    20145327 <网络对抗>Web安全基础实践 实践过程 webgoat开启 java -jar webgoat-container-7.0.1-war-exec.jar 在浏览器输入l ...

  3. ArrayList初始化的4种方法

    In the last post we discussed about class ArrayList in Javaand it’s important methods. Here we are s ...

  4. Django框架(四) Django之视图层

    视图函数 一个视图函数,简称视图,是一个简单的Python 函数,它接受Web请求并且返回Web响应.响应可以是一张网页的HTML内容,一个重定向,一个404错误,一个XML文档,或者一张图片. . ...

  5. python学习笔记比较全

    注:本笔记基于python2.6而编辑,尽量的偏向3.x的语法 Python的特色 1.简单 2.易学 3.免费.开源 4.高层语言: 封装内存管理等 5.可移植性: 程序如果避免使用依赖于系统的特性 ...

  6. linux下去掉pdf的密码(前提:知道密码)

    一.背景 Linux jello 4.16.3 SMP Thu Apr 19 07:32:02 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux 二.去掉密码 2.1 先 ...

  7. linux交叉编译gcc4.8.3

    1.环境: Ubuntu 16.04 2.获取 wget mirrors.ustc.edu.cn/gnu/gcc/gcc-4.8.3/gcc-4.8.3.tar.bz2 3.解压 tar xvf gc ...

  8. Ubuntu 下 su:authentication failure的解决办法

    Ubuntu下使用 su 切换到超级用户时候遇到下面的问题 su: Authentication failure 解决办法: $ sudo passwd root Enter new UNIX pas ...

  9. tyvj 2075 [NOIP2012T5]借教室 区间更新+二分

    描述 在大学期间,经常需要租借教室.大到院系举办活动,小到学习小组自习讨论,都需要向学校申请借教室.教室的大小功能不同,借教室人的身份不同,借教室的手续也不一样.面对海量租借教室的信息,我们自然希望编 ...

  10. Error updating database. Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: 'as3'

    执行更新时的出错信息 Whitelabel Error Page This application has no explicit mapping for /error, so you are see ...