X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=python_ml%2Fvalidate-detection.py;h=4c23c9069a1c5c76ed1070f42aa432d2f46ba7bc;hb=64b083ce3b1a5923f16dfc2c7a937c79ed22104c;hp=b22e0a381cfdd113720a14b45d268b5c0b7a80c2;hpb=3a37f6b96717063a93ff2c06a7d551156c454424;p=pingpong.git diff --git a/python_ml/validate-detection.py b/python_ml/validate-detection.py index b22e0a3..4c23c90 100644 --- a/python_ml/validate-detection.py +++ b/python_ml/validate-detection.py @@ -1,10 +1,78 @@ from datetime import datetime +path = "/scratch/July-2018/experimental_result/smarthome/" +#path = "/scratch/July-2018/experimental_result/standalone/" +# D-Link plug +#device = "dlink-plug/self-test" +#fileExperiment = "dlink-plug-nov-7-2018.timestamps" +#fileDetection = "device-side-detection" +#fileDetection = "phone-side-detection" +#device = "dlink-plug/timestamps" +#fileExperiment = "dlink-plug-smarthome-nov-8-2018.timestamps" +#fileDetection = "dlink-plug-smarthome-nov-8-2018.phone.wlan1.detections" +#fileDetection = "dlink-plug-smarthome-nov-8-2018.phone.eth0.detections" +#fileDetection = "dlink-plug-smarthome-nov-8-2018.device.eth0.detections" + +# TP-Link plug +#device = "tplink-plug/self-test" +#fileExperiment = "tplink-plug-nov-8-2018.timestamps" +#fileDetection = "device-side-detection" +#fileDetection = "phone-side-detection" +#device = "tplink-plug/timestamps" +#fileExperiment = "tplink-plug-smarthome-nov-9-2018.timestamps" +#fileDetection = "tplink-plug-smarthome-nov-9-2018.eth0.device.detections" +#fileDetection = "tplink-plug-smarthome-nov-9-2018.wlan1.phone.detections" + +# D-Link siren +#device = "dlink-siren/self-test" +#fileExperiment = "dlink-siren-nov-9-2018.timestamps" +#fileDetection = "phone-side-detection" +#device = "dlink-siren/timestamps" +#fileExperiment = "dlink-siren-smarthome-nov-10-2018.timestamps" +#fileDetection = "dlink-siren-smarthome-nov-10-2018.eth0.phone.detections" + +# Kwikset door lock +#device = "kwikset-doorlock/self-test" +#fileExperiment = "kwikset-doorlock-nov-10-2018.timestamps" +#fileDetection = "phone-side-detection" +#device = "kwikset-doorlock/timestamps" +#fileExperiment = "kwikset-doorlock-smarthome-nov-10-2018.timestamps" +#fileDetection = "kwikset-doorlock-smarthome-nov-10-2018.eth0.phone.detections" + +# SmartThings plug +#device = "st-plug/self-test" +#fileExperiment = "st-plug-nov-13-2018.timestamps" +#fileDetection = "phone-side-detection" +device = "st-plug/timestamps" +fileExperiment = "st-plug-smarthome-nov-13-2018.timestamps" +fileDetection = "st-plug-smarthome-nov-13-2018.eth0.phone.detections" + + +# 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" -path = "/scratch/July-2018/evaluation/" -device = "dlink" -fileExperiment = "dlink-plug-8hr-data-oct-8-2018.timestamps" -fileDetection = "dlink-plug.detection.timestamps" TIME_WINDOW = 15 # detection/signature window of 15 seconds #NEG_TIME_WINDOW = -15 # detection/signature window of 15 seconds @@ -32,13 +100,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):