keras-anomaly-detection

Anomaly detection implemented in Keras

The source codes of the recurrent, convolutional and feedforward networks auto-encoders for anomaly detection can be found in keras_anomaly_detection/library/convolutional.py and keras_anomaly_detection/library/recurrent.py and keras_anomaly_detection/library/feedforward.py

The the anomaly detection is implemented using auto-encoder with convolutional, feedforward, and recurrent networks and can be applied to:

  • timeseries data to detect timeseries time windows that have anomaly pattern

  • structured data (i.e., tabular data) to detect anomaly in data records
    • Conv1DAutoEncoder in keras_anomaly_detection/library/convolutional.py
    • FeedforwardAutoEncoder in keras_anomaly_detection/library/feedforward.py
       
      看LSTM的模型吧:

          def create_model(time_window_size, metric):
      model = Sequential()
      model.add(LSTM(units=128, input_shape=(time_window_size, 1), return_sequences=False)) model.add(Dense(units=time_window_size, activation='linear')) model.compile(optimizer='adam', loss='mean_squared_error', metrics=[metric])
      print(model.summary())
      return model

      再看feedforward的模型:

          def create_model(self, input_dim):
      encoding_dim = 14
      input_layer = Input(shape=(input_dim,)) encoder = Dense(encoding_dim, activation="tanh",
      activity_regularizer=regularizers.l1(10e-5))(input_layer)
      encoder = Dense(encoding_dim // 2, activation="relu")(encoder) decoder = Dense(encoding_dim // 2, activation='tanh')(encoder)
      decoder = Dense(input_dim, activation='relu')(decoder) model = Model(inputs=input_layer, outputs=decoder)
      model.compile(optimizer='adam',
      loss='mean_squared_error',
      metrics=['accuracy'])

      CNN的:

          def create_model(time_window_size, metric):
      model = Sequential()
      model.add(Conv1D(filters=256, kernel_size=5, padding='same', activation='relu',
      input_shape=(time_window_size, 1)))
      model.add(GlobalMaxPool1D()) model.add(Dense(units=time_window_size, activation='linear')) model.compile(optimizer='adam', loss='mean_squared_error', metrics=[metric])
      print(model.summary())
      return model

      都是将输出设置成自己,异常点就是查看偏离那90%的预测error较大的点。

keras-anomaly-detection 代码分析——本质上就是SAE、LSTM时间序列预测的更多相关文章

  1. DQN 处理 CartPole 问题——使用强化学习,本质上是训练MLP,预测每一个动作的得分

    代码: # -*- coding: utf-8 -*- import random import gym import numpy as np from collections import dequ ...

  2. Kesci: Keras 实现 LSTM——时间序列预测

    博主之前参与的一个科研项目是用 LSTM 结合 Attention 机制依据作物生长期内气象环境因素预测作物产量.本篇博客将介绍如何用 keras 深度学习的框架搭建 LSTM 模型对时间序列做预测. ...

  3. Social LSTM 实现代码分析

    ----- 2019.8.5更新 实现代码思维导图 ----- ----- 初始原文 ----- Social LSTM最早提出于文献 "Social LSTM: Human Traject ...

  4. C++卷积神经网络实例:tiny_cnn代码具体解释(8)——partial_connected_layer层结构类分析(上)

    在之前的博文中我们已经将顶层的网络结构都介绍完毕,包括卷积层.下採样层.全连接层,在这篇博文中主要有两个任务.一是总体贯通一下卷积神经网络在对图像进行卷积处理的整个流程,二是继续我们的类分析.这次须要 ...

  5. 详细分析 Java 中实现多线程的方法有几种?(从本质上出发)

    详细分析 Java 中实现多线程的方法有几种?(从本质上出发) 正确的说法(从本质上出发) 实现多线程的官方正确方法: 2 种. Oracle 官网的文档说明 方法小结 方法一: 实现 Runnabl ...

  6. Coursera 机器学习 第9章(上) Anomaly Detection 学习笔记

    9 Anomaly Detection9.1 Density Estimation9.1.1 Problem Motivation异常检测(Density Estimation)是机器学习常见的应用, ...

  7. Eclipse插件(导出UML图,打开文件资源管理器插件,静态代码分析工具PMD,在eclipse上安装插件)

    目录 能够导出UML图的Eclipse插件 打开文件资源管理器插件 Java静态代码分析工具PMD 如何在eclipse上安装插件 JProfiler性能分析工具 从更新站点安装EclEmma 能够导 ...

  8. Anomaly Detection for Time Series Data with Deep Learning——本质分类正常和异常的行为,对于检测异常行为,采用预测正常行为方式来做

    A sample network anomaly detection project Suppose we wanted to detect network anomalies with the un ...

  9. leetcode 784. Letter Case Permutation——所有BFS和DFS的题目本质上都可以抽象为tree,这样方便你写代码

    Given a string S, we can transform every letter individually to be lowercase or uppercase to create ...

随机推荐

  1. 如何用tomcat发布自己的Java项目

    如何用tomcat发布自己的Java项目 tomcat是什么?它是一个免费的开放源代码的Web 应用服务器,属于轻量级应用服务器.我们用Java开发出来的web项目,通过tomcat发布出来,别人就可 ...

  2. 编译错误 error C2451: “std::_Unforced”类型的条件表达式是非法的

    part 1 编译器 vs2015 VC++. 完整的错误信息粘贴如下: d:\program files (x86)\microsoft visual studio 14.0\vc\include\ ...

  3. switch to hexo !

    用 hexo 搭了个博客 但是由于本博客内容过多,所以对于少数内容搬迁,而且本博客和那个博客相关联,但是这个博客不再更新. 新站地址 再见!

  4. 详解 HTML5 中的 WebSocket 及实例代码-做弹幕

    原文链接:http://www.php.cn/html5-tutorial-363345.html

  5. 20145333茹翔 Exp8 Web基础

    20145333茹翔 Exp8 Web基础 实验问题回答 (1)什么是表单 表单是一个包含表单元素的区域,表单元素是允许用户在表单中(比如:文本域.下拉列表.单选框.复选框等等)输入信息的元素,表单在 ...

  6. HttpClient4.5简单使用

    一.HttpClient简介 HttpClient是一个客户端的HTTP通信实现库,它不是一个浏览器.关于HTTP协议,可以搜索相关的资料.它设计的目的是发送与接收HTTP报文.它不会执行嵌入在页面中 ...

  7. javascript 构造函数类和原型 prototyp e定义的属性和方法的区别

    1.把方法写在原型中比写在构造函数中消耗的内存更小,因为在内存中一个类的原型只有一个,写在原型中的行为可以被所有实例共享,实例化的时候并不会在实例的内存中再复制一份而写在类中的方法,实例化的时候会在每 ...

  8. Node10.15.0的安装

    1. 首先我们需要去node官网下载最近版本的压缩包,然后我们把他们解压到我们自定义的安装路径,我使用的是/usr/local/lib/nodejs VERSION=v10.15.0 DISTRO=l ...

  9. 如何将一个Winform嵌入到一个Control当中

    /// <summary> /// 将一个winform窗体嵌入control中 /// </summary> /// <param name="f" ...

  10. 【源码编译】spark源码编译

    本文采用cdh版本spark-1.6.0-cdh5.12.0 1.源码包下载 2.进入根目录编译,编译的方式有2种 maven mvn clean package \ -DskipTests -Pha ...