cesar před 1 dnem
rodič
revize
89ac667529

binární
model_v1_0._checkpoint.weights.h5 Zobrazit soubor


binární
model_v1_1._checkpoint.weights.h5 Zobrazit soubor


binární
model_v1_2._checkpoint.weights.h5 Zobrazit soubor


binární
model_v1_3._checkpoint.weights.h5 Zobrazit soubor


binární
model_v1_4._checkpoint.weights.h5 Zobrazit soubor


+ 43
- 3
v1_multifailure.py Zobrazit soubor

@@ -40,8 +40,12 @@ datafiles[4]=['2024-12-28_5_','2024-12-29_5_','2024-12-30_5_','2024-12-31_5_','2
40 40
 #datafiles[4]=[] 
41 41
 
42 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 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 49
 NumFeatures=len(features)
46 50
 
47 51
 df_list=[]
@@ -191,7 +195,7 @@ if options.train:
191 195
                 axes[i][j].plot(history[r].history["loss"], label="Training Loss")
192 196
                 axes[i][j].plot(history[r].history["val_loss"], label="Val Loss")
193 197
                 axes[i][j].legend()
194
-    plt.show()
198
+    #plt.show()
195 199
 else:
196 200
     for i in range(NumberOfFailures+1):
197 201
         model[i].load_weights(path_checkpoint[i])
@@ -307,6 +311,8 @@ colorline=['violet','lightcoral','cyan','lime','grey']
307 311
 colordot=['darkviolet','red','blue','green','black']
308 312
 
309 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 316
 indexesToPlot=[]
311 317
 for i in featuresToPlot:
312 318
     indexesToPlot.append(features.index(i))
@@ -344,5 +350,39 @@ def plotData3():
344 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.