cesar 16 hours ago
parent
commit
6be1cfd48c

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


+ 18
- 11
v1_multifailure.py View File

46
 features=['r1 s1','r1 s4','r1 s5','pa1 apiii']
46
 features=['r1 s1','r1 s4','r1 s5','pa1 apiii']
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']
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
 
48
 
49
+#features=['r2 s2', 'tc s1','r1 s10','r1 s6','r2 s8']
50
+
49
 NumFeatures=len(features)
51
 NumFeatures=len(features)
50
 
52
 
51
 df_list=[]
53
 df_list=[]
114
     #axes[1].legend()
116
     #axes[1].legend()
115
     #axes[0].set_ylabel(features[0])
117
     #axes[0].set_ylabel(features[0])
116
     #axes[1].set_ylabel(features[1])
118
     #axes[1].set_ylabel(features[1])
117
-    plt.show()
119
+    #plt.show()
118
 
120
 
119
 #plotData()
121
 #plotData()
120
 
122
 
353
 
355
 
354
 
356
 
355
 def anomalyMetric(testList):  # first of list is non failure data
357
 def anomalyMetric(testList):  # first of list is non failure data
358
+    # FP, TP: false/true positive
359
+    # TN, FN: true/false negative
360
+    # Sensitivity: probab of fail detection if data is fail
361
+    # Specificity: prob of no fail detection if data is well
356
     x_test = create_sequences(testList[0])
362
     x_test = create_sequences(testList[0])
357
     x_test_pred = model[0].predict(x_test)
363
     x_test_pred = model[0].predict(x_test)
358
     test_mae_loss = np.mean(np.abs(x_test_pred - x_test), axis=1)
364
     test_mae_loss = np.mean(np.abs(x_test_pred - x_test), axis=1)
361
     for i in range(anomalies.shape[0]):
367
     for i in range(anomalies.shape[0]):
362
         if AtLeastOneTrue(anomalies[i]):
368
         if AtLeastOneTrue(anomalies[i]):
363
             count+=1
369
             count+=1
364
-    FP=count/anomalies.shape[0]
370
+    FP=count
371
+    TN=anomalies.shape[0]-1
365
     count=0
372
     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))
373
+    TP=np.zeros((NumberOfFailures))
374
+    FN=np.zeros((NumberOfFailures))
371
     for i in range(1,len(testList)):
375
     for i in range(1,len(testList)):
372
         x_test = create_sequences(testList[i])
376
         x_test = create_sequences(testList[i])
373
         x_test_pred = model[0].predict(x_test)
377
         x_test_pred = model[0].predict(x_test)
377
         for j in range(anomalies.shape[0]):
381
         for j in range(anomalies.shape[0]):
378
             if AtLeastOneTrue(anomalies[j]):
382
             if AtLeastOneTrue(anomalies[j]):
379
                 count+=1
383
                 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
+        TP[i-1] = count
385
+        FN[i-1] = anomalies.shape[0]-count
386
+    Sensitivity=TP.sum()/(TP.sum()+FN.sum())
387
+    Specifity=TN/(TN+FP)
388
+    print("Sensitivity: ",Sensitivity)
389
+    print("Specifity: ",Specifity)
390
+    return Sensitivity+Specifity
384
 
391
 
385
 
392
 
386
 
393
 

Powered by TurnKey Linux.