Keras-anomaly-detection code analysis-essentially SAE and lstm time series prediction

Source: Internet
Author: User
Tags keras
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 anomaly detection is implemented using auto-Encoder with convolutional, feedforward, and recurrent networks and can be applied:

  • Timeseries data to detect Timeseries time windows that have Anomaly Pattern
    • Lstmautoencoder in keras_anomaly_detection/library/Recurrent. py
    • Conv1dautoencoder in keras_anomaly_detection/library/convolutional. py
    • Cnnlstmautoencoder in keras_anomaly_detection/library/Recurrent. py
    • Bidirectionallstmautoencoder in keras_anomaly_detection/library/Recurrent. py
  • 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:
          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

      Let's look at the feedforward model:

          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

      Set the output to your own. The exception points are the points with a larger predicted error deviation of the 90%.

Keras-anomaly-detection code analysis-essentially SAE and lstm time series prediction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.