cesar 1 day ago
parent
commit
89ac667529

BIN
model_v1_0._checkpoint.weights.h5 View File


BIN
model_v1_1._checkpoint.weights.h5 View File


BIN
model_v1_2._checkpoint.weights.h5 View File


BIN
model_v1_3._checkpoint.weights.h5 View File


BIN
model_v1_4._checkpoint.weights.h5 View File


+ 43
- 3
v1_multifailure.py View File

40
 #datafiles[4]=[] 
40
 #datafiles[4]=[] 
41
 
41
 
42
 # Features suggested by Xavier
42
 # Features suggested by Xavier
43
+# Care with 'tc s3' because on datafiles[0] is always nulll
44
+# Seems to be incoropored in new tests
45
+
43
 features=['r1 s1','r1 s4','r1 s5','pa1 apiii']
46
 features=['r1 s1','r1 s4','r1 s5','pa1 apiii']
44
-features=['r1 s1','r1 s2','r1 s3','r1 s4','r1 s5','r1 s6','r1 s7','r1 s8','r1 s9','r1 s10','r2 s1','r2 s2','r2 s3','r2 s4','r2 s5','r2 s6','r2 s7','r2 s8','r2 s9','pa1 apiii','tc s1','tc s2','tc s3']
47
+features=['r1 s1','r1 s2','r1 s3','r1 s4','r1 s5','r1 s6','r1 s7','r1 s8','r1 s9','r1 s10','r2 s1','r2 s2','r2 s3','r2 s4','r2 s5','r2 s6','r2 s7','r2 s8','r2 s9','pa1 apiii','tc s1','tc s2']
48
+
45
 NumFeatures=len(features)
49
 NumFeatures=len(features)
46
 
50
 
47
 df_list=[]
51
 df_list=[]
191
                 axes[i][j].plot(history[r].history["loss"], label="Training Loss")
195
                 axes[i][j].plot(history[r].history["loss"], label="Training Loss")
192
                 axes[i][j].plot(history[r].history["val_loss"], label="Val Loss")
196
                 axes[i][j].plot(history[r].history["val_loss"], label="Val Loss")
193
                 axes[i][j].legend()
197
                 axes[i][j].legend()
194
-    plt.show()
198
+    #plt.show()
195
 else:
199
 else:
196
     for i in range(NumberOfFailures+1):
200
     for i in range(NumberOfFailures+1):
197
         model[i].load_weights(path_checkpoint[i])
201
         model[i].load_weights(path_checkpoint[i])
307
 colordot=['darkviolet','red','blue','green','black']
311
 colordot=['darkviolet','red','blue','green','black']
308
 
312
 
309
 featuresToPlot=['r1 s1','r1 s3','r1 s5','r2 s3','r2 s4','pa1 apiii','tc s1','tc s2','tc s3']
313
 featuresToPlot=['r1 s1','r1 s3','r1 s5','r2 s3','r2 s4','pa1 apiii','tc s1','tc s2','tc s3']
314
+featuresToPlot=features
315
+
310
 indexesToPlot=[]
316
 indexesToPlot=[]
311
 for i in featuresToPlot:
317
 for i in featuresToPlot:
312
     indexesToPlot.append(features.index(i))
318
     indexesToPlot.append(features.index(i))
344
     plt.show()
350
     plt.show()
345
 
351
 
346
 
352
 
347
-plotData3()
348
 
353
 
354
+
355
+def anomalyMetric(testList):  # first of list is non failure data
356
+    x_test = create_sequences(testList[0])
357
+    x_test_pred = model[0].predict(x_test)
358
+    test_mae_loss = np.mean(np.abs(x_test_pred - x_test), axis=1)
359
+    anomalies = test_mae_loss > threshold[0]
360
+    count=0
361
+    for i in range(anomalies.shape[0]):
362
+        if AtLeastOneTrue(anomalies[i]):
363
+            count+=1
364
+    FP=count/anomalies.shape[0]
365
+    count=0
366
+    for i in range(anomalies.shape[0]):
367
+        if AtLeastOneTrue(anomalies[i]):
368
+            count+=1
369
+    FP=count/anomalies.shape[0]
370
+    TN=np.zeros((NumberOfFailures))
371
+    for i in range(1,len(testList)):
372
+        x_test = create_sequences(testList[i])
373
+        x_test_pred = model[0].predict(x_test)
374
+        test_mae_loss = np.mean(np.abs(x_test_pred - x_test), axis=1)
375
+        anomalies = test_mae_loss > threshold[0]
376
+        count=0
377
+        for j in range(anomalies.shape[0]):
378
+            if AtLeastOneTrue(anomalies[j]):
379
+                count+=1
380
+        TN[i-1] = count/anomalies.shape[0]
381
+    print("FP: ",FP)
382
+    print("TN: ",TN)
383
+    return (1-FP)*NumberOfFailures+TN.sum()
384
+
385
+
386
+
387
+anomalyMetric([dataTestNorm[0],dataTestNorm[1],dataTestNorm[2],dataTestNorm[3],dataTestNorm[4]])
388
+plotData3()

Powered by TurnKey Linux.