我正在嘗試使用 LSTM 進行例外檢測。我能夠用區域和全域例外繪制所有特征,但我無法一起列印所有例外值、日期時間、損失、閾值和日期(如表格)。
按以下方式計算測驗和訓練 MAE 后:
Y_train_pred = self.model.predict(self.X_train)
train_mae_loss = np.mean(np.abs(self.Y_train_pred - self.Y_train), axis=1)
Y_test_pred = self.model.predict(self.X_test)
test_mae_loss = np.mean(np.abs(self.Y_test_pred - self.Y_test), axis=1)
test = self.test[:len(Y_test_pred)]
我嘗試通過這種方式匹配日期、損失、閾值和例外來制作表格:
test_score_df = pd.DataFrame(index=self.test.index)
print(test_score_df)
test_score_df['loss'] = loss_mean_vec
test_score_df['threshold'] = threshold_mean_exp
test_score_df['anomaly'] = test_score_df.loss > test_score_df.threshold
test_score_df['dckw'] = self.test[:].dckw
anomalies = test_score_df[test_score_df.anomaly == True]
print(anomalies.head())
但它拋出并出錯:
AttributeError: 'DataFrame' object has no attribute 'dckw'
當我列印 self.test 它具有標題 datetimeAt, dckw 的所有功能......
當我洗掉這一行 test_score_df['dckw'] = self.test[:].dckw
它給了我這個結果:
loss threshold anomaly
0 0.106414 0.037134 True
1 0.107169 0.037134 True
2 0.107001 0.037134 True
3 0.105836 0.037134 True
4 0.103779 0.037134 True
那么我怎樣才能獲得包含日期時間和 csv 檔案中的其他功能的最后一個表,以便我可以繪制日期時間并查看例外出現的時間?
我的代碼和檔案很重,所以我將它們上傳到 git hub:
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/391937.html
