Adding a method to delete a bad sequence in a signature after we test the produced...
[pingpong.git] / python_ml / validate-detection.py
index b22e0a381cfdd113720a14b45d268b5c0b7a80c2..8b04ead4e49868ae3e13a89d1948468401d2a22f 100644 (file)
@@ -1,10 +1,37 @@
 from datetime import datetime
 
 
-path = "/scratch/July-2018/evaluation/"
-device = "dlink"
-fileExperiment = "dlink-plug-8hr-data-oct-8-2018.timestamps"
-fileDetection = "dlink-plug.detection.timestamps"
+path = "/scratch/July-2018/training/"
+# D-Link plug
+#device = "dlink-plug/self-test"
+#fileExperiment = "dlink-plug-oct-17-2018.timestamps"
+#fileDetection = "detection-on-training-device-side"
+#fileDetection = "detection-on-training-phone-side"
+# Arlo camera
+#device = "arlo-camera/self-test"
+#fileExperiment = "arlo-camera-aug-10-2018.timestamps"
+#fileDetection = "detection-on-training-phone-side"
+# Blossom sprinkler
+#device = "blossom-sprinkler/self-test"
+#fileExperiment = "blossom-sprinkler-aug-13-2018.timestamps"
+#fileDetection = "detection-on-training-device-side"
+# Nest thermostat
+device = "nest-thermostat/self-test"
+fileExperiment = "nest-aug-15-2018.timestamps"
+fileDetection = "detection-on-training-phone-side"
+# Hue bulb
+#device = "hue-bulb/self-test"
+#fileExperiment = "hue-bulb-aug-7-2018.timestamps"
+#fileDetection = "detection-on-training-phone-side"
+# TPLink bulb
+#device = "tplink-bulb/self-test"
+#fileExperiment = "tplink-bulb-aug-3-2018.timestamps"
+#fileDetection = "detection-on-training-phone-side"
+# WeMo Insight Plug
+#device = "wemo-insight-plug/self-test"
+#fileExperiment = "wemo-insight-july-31-2018.timestamps"
+#fileDetection = "detection-on-training-device-side"
+
 TIME_WINDOW = 15 # detection/signature window of 15 seconds
 #NEG_TIME_WINDOW = -15 # detection/signature window of 15 seconds
 
@@ -32,13 +59,19 @@ else:
 i = 0
 j = 0
 while i < maxTimestamps:
+       if(len(tsExperimentList) <= i or len(tsDetectionList) <= j):
+               break;
+       
        tsE = tsExperimentList[i]
        tsD = tsDetectionList[j]
        # Detection is always a bit later than training trigger
-       delta = tsD - tsE
+       delta1 = tsD - tsE
+       delta2 = tsE - tsD
+       #print("tsE: " + str(tsE) + " - tsD: " + str(tsD) + " - delta1: " + str(delta1.seconds) + " - delta2: " + str(delta2.seconds))
        # The following happens when we could detect less triggers than the experiment
-       if (delta.seconds > TIME_WINDOW):
+       if (delta1.seconds > TIME_WINDOW and delta2.seconds > TIME_WINDOW):
                print("Missing trigger at line: " + str(i) + ", t_experiment: " + str(tsE) + " and t_detection: " + str(tsD))
+               #print(str(tsD))
                i = i + 1
        # The following should not happen (we have more detected triggers than the experiment)
        #elif (delta.seconds < NEG_TIME_WINDOW):