I have sensor data like this and it's unsupervised and it has almost 800 features. my use-case is for anomaly detection. I applied Principal component analysis (PCA) for dimensionality reduction. now i got 20 Principal component which i am going to use as features to fit autoencoder.
I am trying to fit autoencoder for anomaly detection use case following this tutorial https://engineering.taboola.com/anomaly-detection-using-lstm-autoencoder/ here is my code. But getting error Nameerror: name 'self' is not defined and please instead of downgrading try to help someone. As I am new to deep learning. I want to know as according to my use case i am i right direction and i need help to fit autoencoder to this is what i tried .
import matplotlib.pyplot as plt import numpy as np import tensorflow as tf from tensorflow.keras.models import Model, Sequential from tensorflow.keras.layers import Dense import pandas as pd import random from sklearn.preprocessing import StandardScaler import os os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' df = pd.read_csv('C:/Users/user/Downloads/un-auto/mydata.csv') df = df.astype('float32') # normalize features scaler = MinMaxScaler(feature_range=(0, 1)) scaled = scaler.fit_transform(df) #Python self.model.add(LSTM(units=64, input_shape=(self.train_X.shape,self.train_X.shape))) self.model.add(Dropout(rate=0.2)) self.model.add(RepeatVector(n=self.train_X.shape)) self.model.add(LSTM(units=64, return_sequences=True)) self.model.add(Dropout(rate=0.2)) self.model.add(TimeDistributed(Dense(self.train_X.shape))) self.model.compile(optimizer='adam', loss='mae') #fit self.history = self.model.fit(self.train_X, self.train_y, epochs=50, batch_size=72, validation_split=0.1, shuffle=False) #predict # Python X_test_pred = self.model.predict(self.test_X) test_mae_loss = np.mean(np.abs(X_test_pred - self.test_X), axis=1) test_mae_loss_avg_vector = np.mean(test_mae_loss, axis=1)