13 changed files with 10974 additions and 0 deletions
@ -0,0 +1,163 @@
|
||||
//Day1 - normal |
||||
{"timestamp": 1737806400, "room": "pillbox", "nodeId": 1, "onOff": true} // 6:00 AM: Pillbox opened |
||||
{"timestamp": 1737806460, "room": "bedroom", "nodeId": 2, "onOff": true} // 6:01 AM: Bedroom light turned on |
||||
{"timestamp": 1737806700, "room": "bathroom", "nodeId": 2, "onOff": true} // 6:05 AM: Bathroom light turned on |
||||
{"timestamp": 1737807000, "room": "bathroom", "nodeId": 3, "humidity": 6500} // 6:10 AM: Humidity spike in bathroom (shower) |
||||
{"timestamp": 1737807300, "room": "bathroom", "nodeId": 2, "onOff": false} // 6:15 AM: Bathroom light turned off |
||||
{"timestamp": 1737807600, "room": "kitchen", "nodeId": 2, "onOff": true} // 6:20 AM: Kitchen light turned on |
||||
{"timestamp": 1737807660, "room": "kitchen", "event": "fridge_opened"} // 6:21 AM: Fridge opened (breakfast preparation) |
||||
{"timestamp": 1737808200, "room": "kitchen", "nodeId": 2, "onOff": false} // 6:30 AM: Kitchen light turned off |
||||
{"timestamp": 1737808500, "room": "livingroom", "nodeId": 2, "onOff": true} // 6:35 AM: Living room light turned on |
||||
{"timestamp": 1737808800, "room": "livingroom", "nodeId": 1, "occupancy": 1} // 6:40 AM: Person 1 sits in the living room |
||||
{"timestamp": 1737810000, "room": "livingroom", "nodeId": 2, "onOff": false} // 7:00 AM: Living room light turned off |
||||
{"timestamp": 1737811200, "room": "hall", "nodeId": 1, "occupancy": 1} // 7:20 AM: Person 1 walks through the hall |
||||
{"timestamp": 1737811800, "room": "porch", "nodeId": 1, "occupancy": 1} // 7:30 AM: Person 1 leaves the house (porch occupancy) |
||||
{"timestamp": 1737811860, "room": "hall", "nodeId": 1, "occupancy": 0} // 7:31 AM: Hall occupancy ends |
||||
{"timestamp": 1737828000, "room": "porch", "nodeId": 1, "occupancy": 1} // 12:00 PM: Person 1 returns home (porch occupancy) |
||||
{"timestamp": 1737828060, "room": "hall", "nodeId": 1, "occupancy": 1} // 12:01 PM: Hall occupancy begins |
||||
{"timestamp": 1737828120, "room": "kitchen", "nodeId": 2, "onOff": true} // 12:02 PM: Kitchen light turned on |
||||
{"timestamp": 1737828180, "room": "kitchen", "event": "fridge_opened"} // 12:03 PM: Fridge opened (lunch preparation) |
||||
{"timestamp": 1737829200, "room": "kitchen", "nodeId": 2, "onOff": false} // 12:20 PM: Kitchen light turned off |
||||
{"timestamp": 1737831600, "room": "livingroom", "nodeId": 2, "onOff": true} // 1:00 PM: Living room light turned on |
||||
{"timestamp": 1737831660, "room": "livingroom", "nodeId": 1, "occupancy": 1} // 1:01 PM: Person 1 sits in the living room |
||||
{"timestamp": 1737835200, "room": "livingroom", "nodeId": 2, "onOff": false} // 2:00 PM: Living room light turned off |
||||
{"timestamp": 1737838800, "room": "bedroom", "nodeId": 2, "onOff": true} // 3:00 PM: Bedroom light turned on |
||||
{"timestamp": 1737838860, "room": "pillbox", "nodeId": 1, "onOff": true} // 3:01 PM: Pillbox opened |
||||
{"timestamp": 1737839400, "room": "bedroom", "nodeId": 2, "onOff": false} // 3:10 PM: Bedroom light turned off |
||||
{"timestamp": 1737849600, "room": "kitchen", "nodeId": 2, "onOff": true} // 6:00 PM: Kitchen light turned on |
||||
{"timestamp": 1737849660, "room": "kitchen", "event": "fridge_opened"} // 6:01 PM: Fridge opened (dinner preparation) |
||||
{"timestamp": 1737850800, "room": "kitchen", "nodeId": 2, "onOff": false} // 6:20 PM: Kitchen light turned off |
||||
{"timestamp": 1737852000, "room": "livingroom", "nodeId": 2, "onOff": true} // 6:40 PM: Living room light turned on |
||||
{"timestamp": 1737852060, "room": "livingroom", "nodeId": 1, "occupancy": 1} // 6:41 PM: Person 1 sits in the living room |
||||
{"timestamp": 1737855600, "room": "livingroom", "nodeId": 2, "onOff": false} // 7:40 PM: Living room light turned off |
||||
{"timestamp": 1737859200, "room": "bedroom", "nodeId": 2, "onOff": true} // 8:40 PM: Bedroom light turned on |
||||
{"timestamp": 1737859260, "room": "pillbox", "nodeId": 1, "onOff": true} // 8:41 PM: Pillbox opened |
||||
{"timestamp": 1737859800, "room": "bedroom", "nodeId": 2, "onOff": false} // 8:50 PM: Bedroom light turned off |
||||
//Day2 - normal |
||||
{"timestamp": 1737892800, "room": "pillbox", "nodeId": 1, "onOff": true} // 6:00 AM: Pillbox opened |
||||
{"timestamp": 1737892860, "room": "bedroom", "nodeId": 2, "onOff": true} // 6:01 AM: Bedroom light turned on |
||||
{"timestamp": 1737893100, "room": "bathroom", "nodeId": 2, "onOff": true} // 6:05 AM: Bathroom light turned on |
||||
{"timestamp": 1737893400, "room": "bathroom", "nodeId": 3, "humidity": 6500} // 6:10 AM: Humidity spike in bathroom (shower) |
||||
{"timestamp": 1737893700, "room": "bathroom", "nodeId": 2, "onOff": false} // 6:15 AM: Bathroom light turned off |
||||
{"timestamp": 1737894000, "room": "kitchen", "nodeId": 2, "onOff": true} // 6:20 AM: Kitchen light turned on |
||||
{"timestamp": 1737894060, "room": "kitchen", "event": "fridge_opened"} // 6:21 AM: Fridge opened (breakfast preparation) |
||||
{"timestamp": 1737894600, "room": "kitchen", "nodeId": 2, "onOff": false} // 6:30 AM: Kitchen light turned off |
||||
{"timestamp": 1737894900, "room": "livingroom", "nodeId": 2, "onOff": true} // 6:35 AM: Living room light turned on |
||||
{"timestamp": 1737895200, "room": "livingroom", "nodeId": 1, "occupancy": 1} // 6:40 AM: Person 1 sits in the living room |
||||
{"timestamp": 1737896400, "room": "livingroom", "nodeId": 2, "onOff": false} // 7:00 AM: Living room light turned off |
||||
{"timestamp": 1737897600, "room": "hall", "nodeId": 1, "occupancy": 1} // 7:20 AM: Person 1 walks through the hall |
||||
{"timestamp": 1737898200, "room": "porch", "nodeId": 1, "occupancy": 1} // 7:30 AM: Person 1 leaves the house (porch occupancy) |
||||
{"timestamp": 1737898260, "room": "hall", "nodeId": 1, "occupancy": 0} // 7:31 AM: Hall occupancy ends |
||||
{"timestamp": 1737914400, "room": "porch", "nodeId": 1, "occupancy": 1} // 12:00 PM: Person 1 returns home (porch occupancy) |
||||
{"timestamp": 1737914460, "room": "hall", "nodeId": 1, "occupancy": 1} // 12:01 PM: Hall occupancy begins |
||||
{"timestamp": 1737914520, "room": "kitchen", "nodeId": 2, "onOff": true} // 12:02 PM: Kitchen light turned on |
||||
{"timestamp": 1737914580, "room": "kitchen", "event": "fridge_opened"} // 12:03 PM: Fridge opened (lunch preparation) |
||||
{"timestamp": 1737915600, "room": "kitchen", "nodeId": 2, "onOff": false} // 12:20 PM: Kitchen light turned off |
||||
{"timestamp": 1737918000, "room": "livingroom", "nodeId": 2, "onOff": true} // 1:00 PM: Living room light turned on |
||||
{"timestamp": 1737918060, "room": "livingroom", "nodeId": 1, "occupancy": 1} // 1:01 PM: Person 1 sits in the living room |
||||
{"timestamp": 1737921600, "room": "livingroom", "nodeId": 2, "onOff": false} // 2:00 PM: Living room light turned off |
||||
{"timestamp": 1737925200, "room": "bedroom", "nodeId": 2, "onOff": true} // 3:00 PM: Bedroom light turned on |
||||
{"timestamp": 1737925260, "room": "pillbox", "nodeId": 1, "onOff": true} // 3:01 PM: Pillbox opened |
||||
{"timestamp": 1737925800, "room": "bedroom", "nodeId": 2, "onOff": false} // 3:10 PM: Bedroom light turned off |
||||
{"timestamp": 1737936000, "room": "kitchen", "nodeId": 2, "onOff": true} // 6:00 PM: Kitchen light turned on |
||||
{"timestamp": 1737936060, "room": "kitchen", "event": "fridge_opened"} // 6:01 PM: Fridge opened (dinner preparation) |
||||
{"timestamp": 1737937200, "room": "kitchen", "nodeId": 2, "onOff": false} // 6:20 PM: Kitchen light turned off |
||||
{"timestamp": 1737938400, "room": "livingroom", "nodeId": 2, "onOff": true} // 6:40 PM: Living room light turned on |
||||
{"timestamp": 1737938460, "room": "livingroom", "nodeId": 1, "occupancy": 1} // 6:41 PM: Person 1 sits in the living room |
||||
{"timestamp": 1737942000, "room": "livingroom", "nodeId": 2, "onOff": false} // 7:40 PM: Living room light turned off |
||||
{"timestamp": 1737945600, "room": "bedroom", "nodeId": 2, "onOff": true} // 8:40 PM: Bedroom light turned on |
||||
{"timestamp": 1737945660, "room": "pillbox", "nodeId": 1, "onOff": true} // 8:41 PM: Pillbox opened |
||||
{"timestamp": 1737946200, "room": "bedroom", "nodeId": 2, "onOff": false} // 8:50 PM: Bedroom light turned off |
||||
//Day3 - normal |
||||
{"timestamp": 1737979200, "room": "pillbox", "nodeId": 1, "onOff": true} // 6:00 AM: Pillbox opened |
||||
{"timestamp": 1737979260, "room": "bedroom", "nodeId": 2, "onOff": true} // 6:01 AM: Bedroom light turned on |
||||
{"timestamp": 1737979500, "room": "bathroom", "nodeId": 2, "onOff": true} // 6:05 AM: Bathroom light turned on |
||||
{"timestamp": 1737979800, "room": "bathroom", "nodeId": 3, "humidity": 6500} // 6:10 AM: Humidity spike in bathroom (shower) |
||||
{"timestamp": 1737980100, "room": "bathroom", "nodeId": 2, "onOff": false} // 6:15 AM: Bathroom light turned off |
||||
{"timestamp": 1737980400, "room": "kitchen", "nodeId": 2, "onOff": true} // 6:20 AM: Kitchen light turned on |
||||
{"timestamp": 1737980460, "room": "kitchen", "event": "fridge_opened"} // 6:21 AM: Fridge opened (breakfast preparation) |
||||
{"timestamp": 1737981000, "room": "kitchen", "nodeId": 2, "onOff": false} // 6:30 AM: Kitchen light turned off |
||||
{"timestamp": 1737981300, "room": "livingroom", "nodeId": 2, "onOff": true} // 6:35 AM: Living room light turned on |
||||
{"timestamp": 1737981600, "room": "livingroom", "nodeId": 1, "occupancy": 1} // 6:40 AM: Person 1 sits in the living room |
||||
{"timestamp": 1737982800, "room": "livingroom", "nodeId": 2, "onOff": false} // 7:00 AM: Living room light turned off |
||||
{"timestamp": 1737984000, "room": "hall", "nodeId": 1, "occupancy": 1} // 7:20 AM: Person 1 walks through the hall |
||||
{"timestamp": 1737984600, "room": "porch", "nodeId": 1, "occupancy": 1} // 7:30 AM: Person 1 leaves the house (porch occupancy) |
||||
{"timestamp": 1737984660, "room": "hall", "nodeId": 1, "occupancy": 0} // 7:31 AM: Hall occupancy ends |
||||
{"timestamp": 1738000800, "room": "porch", "nodeId": 1, "occupancy": 1} // 12:00 PM: Person 1 returns home (porch occupancy) |
||||
{"timestamp": 1738000860, "room": "hall", "nodeId": 1, "occupancy": 1} // 12:01 PM: Hall occupancy begins |
||||
{"timestamp": 1738000920, "room": "kitchen", "nodeId": 2, "onOff": true} // 12:02 PM: Kitchen light turned on |
||||
{"timestamp": 1738000980, "room": "kitchen", "event": "fridge_opened"} // 12:03 PM: Fridge opened (lunch preparation) |
||||
{"timestamp": 1738002000, "room": "kitchen", "nodeId": 2, "onOff": false} // 12:20 PM: Kitchen light turned off |
||||
{"timestamp": 1738004400, "room": "livingroom", "nodeId": 2, "onOff": true} // 1:00 PM: Living room light turned on |
||||
{"timestamp": 1738004460, "room": "livingroom", "nodeId": 1, "occupancy": 1} // 1:01 PM: Person 1 sits in the living room |
||||
{"timestamp": 1738008000, "room": "livingroom", "nodeId": 2, "onOff": false} // 2:00 PM: Living room light turned off |
||||
{"timestamp": 1738011600, "room": "bedroom", "nodeId": 2, "onOff": true} // 3:00 PM: Bedroom light turned on |
||||
{"timestamp": 1738011660, "room": "pillbox", "nodeId": 1, "onOff": true} // 3:01 PM: Pillbox opened |
||||
{"timestamp": 1738012200, "room": "bedroom", "nodeId": 2, "onOff": false} // 3:10 PM: Bedroom light turned off |
||||
{"timestamp": 1738022400, "room": "kitchen", "nodeId": 2, "onOff": true} // 6:00 PM: Kitchen light turned on |
||||
{"timestamp": 1738022460, "room": "kitchen", "event": "fridge_opened"} // 6:01 PM: Fridge opened (dinner preparation) |
||||
{"timestamp": 1738023600, "room": "kitchen", "nodeId": 2, "onOff": false} // 6:20 PM: Kitchen light turned off |
||||
{"timestamp": 1738024800, "room": "livingroom", "nodeId": 2, "onOff": true} // 6:40 PM: Living room light turned on |
||||
{"timestamp": 1738024860, "room": "livingroom", "nodeId": 1, "occupancy": 1} // 6:41 PM: Person 1 sits in the living room |
||||
{"timestamp": 1738028400, "room": "livingroom", "nodeId": 2, "onOff": false} // 7:40 PM: Living room light turned off |
||||
{"timestamp": 1738032000, "room": "bedroom", "nodeId": 2, "onOff": true} // 8:40 PM: Bedroom light turned on |
||||
{"timestamp": 1738032060, "room": "pillbox", "nodeId": 1, "onOff": true} // 8:41 PM: Pillbox opened |
||||
{"timestamp": 1738032600, "room": "bedroom", "nodeId": 2, "onOff": false} // 8:50 PM: Bedroom light turned off |
||||
|
||||
// Normal: Daily routine |
||||
{"timestamp": 1737806400, "room": "pillbox", "nodeId": 1, "onOff": true} // 6:00 AM: Pillbox opened |
||||
{"timestamp": 1737806460, "room": "bedroom", "nodeId": 2, "onOff": true} // 6:01 AM: Bedroom light turned on |
||||
{"timestamp": 1737806700, "room": "bathroom", "nodeId": 2, "onOff": true} // 6:05 AM: Bathroom light turned on |
||||
{"timestamp": 1737807000, "room": "bathroom", "nodeId": 3, "humidity": 6500} // 6:10 AM: Humidity spike in bathroom (shower) |
||||
{"timestamp": 1737807300, "room": "bathroom", "nodeId": 2, "onOff": false} // 6:15 AM: Bathroom light turned off |
||||
{"timestamp": 1737807600, "room": "kitchen", "nodeId": 2, "onOff": true} // 6:20 AM: Kitchen light turned on |
||||
{"timestamp": 1737807660, "room": "kitchen", "event": "fridge_opened"} // 6:21 AM: Fridge opened (breakfast preparation) |
||||
{"timestamp": 1737808200, "room": "kitchen", "nodeId": 2, "onOff": false} // 6:30 AM: Kitchen light turned off |
||||
{"timestamp": 1737808500, "room": "livingroom", "nodeId": 2, "onOff": true} // 6:35 AM: Living room light turned on |
||||
{"timestamp": 1737808800, "room": "livingroom", "nodeId": 1, "occupancy": 1} // 6:40 AM: Person 1 sits in the living room |
||||
{"timestamp": 1737810000, "room": "livingroom", "nodeId": 2, "onOff": false} // 7:00 AM: Living room light turned off |
||||
{"timestamp": 1737811200, "room": "hall", "nodeId": 1, "occupancy": 1} // 7:20 AM: Person 1 walks through the hall |
||||
{"timestamp": 1737811800, "room": "porch", "nodeId": 1, "occupancy": 1} // 7:30 AM: Person 1 leaves the house (porch occupancy) |
||||
{"timestamp": 1737811860, "room": "hall", "nodeId": 1, "occupancy": 0} // 7:31 AM: Hall occupancy ends |
||||
|
||||
// Anomalous: No fridge activity for 6 hours |
||||
{"timestamp": 1737828000, "room": "porch", "nodeId": 1, "occupancy": 1} // 12:00 PM: Person 1 returns home (porch occupancy) |
||||
{"timestamp": 1737828060, "room": "hall", "nodeId": 1, "occupancy": 1} // 12:01 PM: Hall occupancy begins |
||||
{"timestamp": 1737828120, "room": "kitchen", "nodeId": 2, "onOff": true} // 12:02 PM: Kitchen light turned on |
||||
{"timestamp": 1737828180, "room": "kitchen", "event": "fridge_opened"} // 12:03 PM: Fridge opened (lunch preparation) |
||||
{"timestamp": 1737829200, "room": "kitchen", "nodeId": 2, "onOff": false} // 12:20 PM: Kitchen light turned off |
||||
|
||||
// Anomalous: Excessive pillbox usage |
||||
{"timestamp": 1737831600, "room": "pillbox", "nodeId": 1, "onOff": true} // 1:00 PM: Pillbox opened |
||||
{"timestamp": 1737831660, "room": "pillbox", "nodeId": 1, "onOff": false} // 1:01 PM: Pillbox closed |
||||
{"timestamp": 1737831720, "room": "pillbox", "nodeId": 1, "onOff": true} // 1:02 PM: Pillbox opened |
||||
{"timestamp": 1737831780, "room": "pillbox", "nodeId": 1, "onOff": false} // 1:03 PM: Pillbox closed |
||||
{"timestamp": 1737831840, "room": "pillbox", "nodeId": 1, "onOff": true} // 1:04 PM: Pillbox opened |
||||
{"timestamp": 1737831900, "room": "pillbox", "nodeId": 1, "onOff": false} // 1:05 PM: Pillbox closed |
||||
|
||||
// Anomalous: No movement in the living room during typical active hours |
||||
{"timestamp": 1737835200, "room": "livingroom", "nodeId": 2, "onOff": false} // 2:00 PM: Living room light remains off |
||||
{"timestamp": 1737838800, "room": "bedroom", "nodeId": 2, "onOff": true} // 3:00 PM: Bedroom light turned on |
||||
{"timestamp": 1737838860, "room": "pillbox", "nodeId": 1, "onOff": true} // 3:01 PM: Pillbox opened |
||||
{"timestamp": 1737839400, "room": "bedroom", "nodeId": 2, "onOff": false} // 3:10 PM: Bedroom light turned off |
||||
|
||||
// Anomalous: Unusual bathroom activity (occupied for 2 hours) |
||||
{"timestamp": 1737849600, "room": "bathroom", "nodeId": 2, "onOff": true} // 6:00 PM: Bathroom light turned on |
||||
{"timestamp": 1737849660, "room": "bathroom", "nodeId": 3, "humidity": 6500} // 6:01 PM: Humidity spike in bathroom |
||||
{"timestamp": 1737850800, "room": "bathroom", "nodeId": 2, "onOff": false} // 6:20 PM: Bathroom light turned off |
||||
|
||||
// Anomalous: Irregular transitions (person leaves and does not return for 12 hours) |
||||
{"timestamp": 1737852000, "room": "hall", "nodeId": 1, "occupancy": 1} // 6:40 PM: Person 1 walks through the hall |
||||
{"timestamp": 1737852600, "room": "porch", "nodeId": 1, "occupancy": 1} // 6:50 PM: Person 1 leaves the house (porch occupancy) |
||||
{"timestamp": 1737852660, "room": "hall", "nodeId": 1, "occupancy": 0} // 6:51 PM: Hall occupancy ends |
||||
|
||||
// Anomalous: No fridge activity for 12 hours |
||||
{"timestamp": 1737859200, "room": "kitchen", "nodeId": 2, "onOff": true} // 8:40 PM: Kitchen light turned on |
||||
{"timestamp": 1737859260, "room": "kitchen", "event": "fridge_opened"} // 8:41 PM: Fridge opened (dinner preparation) |
||||
{"timestamp": 1737859800, "room": "kitchen", "nodeId": 2, "onOff": false} // 8:50 PM: Kitchen light turned off |
||||
{"timestamp": 1737860400, "room": "livingroom", "nodeId": 2, "onOff": true} // 9:00 PM: Living room light turned on |
||||
{"timestamp": 1737860460, "room": "livingroom", "nodeId": 1, "occupancy": 1} // 9:01 PM: Person 1 sits in the living room |
||||
{"timestamp": 1737864000, "room": "livingroom", "nodeId": 2, "onOff": false} // 10:00 PM: Living room light turned off |
||||
{"timestamp": 1737867600, "room": "bedroom", "nodeId": 2, "onOff": true} // 11:00 PM: Bedroom light turned on |
||||
{"timestamp": 1737867660, "room": "pillbox", "nodeId": 1, "onOff": true} // 11:01 PM: Pillbox opened |
||||
{"timestamp": 1737868200, "room": "bedroom", "nodeId": 2, "onOff": false} // 11:10 PM: Bedroom light turned off |
File diff suppressed because one or more lines are too long
@ -0,0 +1,60 @@
|
||||
{ |
||||
"rules": [ |
||||
{ |
||||
"input": "Fridge opened, light on in kitchen, pillbox opened, movement in living room", |
||||
"label": "normal" |
||||
}, |
||||
{ |
||||
"input": "Fridge not opened for 12 hours, no movement detected in living room", |
||||
"label": "abnormal" |
||||
}, |
||||
{ |
||||
"input": "Temperature in garage is 2863°C, humidity is 5773", |
||||
"label": "abnormal" |
||||
}, |
||||
{ |
||||
"input": "Pillbox opened multiple times in bedroom, occupancy detected", |
||||
"label": "normal" |
||||
}, |
||||
{ |
||||
"input": "Bathroom light off, occupancy 0, humidity 6393", |
||||
"label": "normal" |
||||
}, |
||||
{ |
||||
"input": "Living room light on, no movement detected for 8 hours", |
||||
"label": "abnormal" |
||||
}, |
||||
{ |
||||
"input": "Fridge opened, kitchen light turned on, occupancy detected in kitchen", |
||||
"label": "normal" |
||||
}, |
||||
{ |
||||
"input": "No movement in garage, temperature 2037°C, humidity 4264", |
||||
"label": "normal" |
||||
}, |
||||
{ |
||||
"input": "Study occupancy 0, light on for extended duration", |
||||
"label": "abnormal" |
||||
}, |
||||
{ |
||||
"input": "Kitchen light on and off multiple times within an hour", |
||||
"label": "normal" |
||||
}, |
||||
{ |
||||
"input": "Living room humidity is 6742, light on, no movement detected", |
||||
"label": "abnormal" |
||||
}, |
||||
{ |
||||
"input": "Pillbox unopened for more than 24 hours", |
||||
"label": "abnormal" |
||||
}, |
||||
{ |
||||
"input": "Bedroom occupancy detected, pillbox opened, light on", |
||||
"label": "normal" |
||||
}, |
||||
{ |
||||
"input": "Temperature in bathroom 2767°C, light on, humidity 5363", |
||||
"label": "normal" |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,498 @@
|
||||
[ |
||||
{ |
||||
"input": [ |
||||
{"timestamp": 1737806400, "room": "pillbox", "nodeId": 1, "onOff": true}, |
||||
{"timestamp": 1737806460, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1737806700, "room": "bathroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1737807000, "room": "bathroom", "nodeId": 3, "humidity": 6500}, |
||||
{"timestamp": 1737807300, "room": "bathroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1737807600, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1737807660, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1737808200, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1737808500, "room": "livingroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1737808800, "room": "livingroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1737810000, "room": "livingroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1737811200, "room": "hall", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1737811800, "room": "porch", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1737811860, "room": "hall", "nodeId": 1, "occupancy": 0}, |
||||
{"timestamp": 1737828000, "room": "porch", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1737828060, "room": "hall", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1737828120, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1737828180, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1737829200, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1737831600, "room": "livingroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1737831660, "room": "livingroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1737835200, "room": "livingroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1737838800, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1737838860, "room": "pillbox", "nodeId": 1, "onOff": true}, |
||||
{"timestamp": 1737839400, "room": "bedroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1737849600, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1737849660, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1737850800, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1737852000, "room": "livingroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1737852060, "room": "livingroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1737855600, "room": "livingroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1737859200, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1737859260, "room": "pillbox", "nodeId": 1, "onOff": true}, |
||||
{"timestamp": 1737859800, "room": "bedroom", "nodeId": 2, "onOff": false} |
||||
], |
||||
"result": "normal", |
||||
"reason": "The data reflects a consistent daily routine, including medication times, meal preparation, and relaxation periods. No unusual activity is detected." |
||||
}, |
||||
{ |
||||
"input": [ |
||||
{"timestamp": 1737892800, "room": "pillbox", "nodeId": 1, "onOff": true}, |
||||
{"timestamp": 1737892860, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1737893100, "room": "bathroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1737893400, "room": "bathroom", "nodeId": 3, "humidity": 6500}, |
||||
{"timestamp": 1737893700, "room": "bathroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1737894000, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1737894060, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1737894600, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1737894900, "room": "livingroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1737895200, "room": "livingroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1737896400, "room": "livingroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1737897600, "room": "hall", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1737898200, "room": "porch", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1737898260, "room": "hall", "nodeId": 1, "occupancy": 0}, |
||||
{"timestamp": 1737914400, "room": "porch", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1737914460, "room": "hall", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1737914520, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1737914580, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1737915600, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1737918000, "room": "livingroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1737918060, "room": "livingroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1737921600, "room": "livingroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1737925200, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1737925260, "room": "pillbox", "nodeId": 1, "onOff": true}, |
||||
{"timestamp": 1737925800, "room": "bedroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1737936000, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1737936060, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1737937200, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1737938400, "room": "livingroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1737938460, "room": "livingroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1737942000, "room": "livingroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1737945600, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1737945660, "room": "pillbox", "nodeId": 1, "onOff": true}, |
||||
{"timestamp": 1737946200, "room": "bedroom", "nodeId": 2, "onOff": false} |
||||
], |
||||
"result": "normal", |
||||
"reason": "The data shows a consistent routine similar to Day 1, with no deviations. All activities align with expected behavior." |
||||
}, |
||||
{ |
||||
"input": [ |
||||
{"timestamp": 1737979200, "room": "pillbox", "nodeId": 1, "onOff": true}, |
||||
{"timestamp": 1737979260, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1737979500, "room": "bathroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1737979800, "room": "bathroom", "nodeId": 3, "humidity": 6500}, |
||||
{"timestamp": 1737980100, "room": "bathroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1737980400, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1737980460, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1737981000, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1737981300, "room": "livingroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1737981600, "room": "livingroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1737982800, "room": "livingroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1737984000, "room": "hall", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1737984600, "room": "porch", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1737984660, "room": "hall", "nodeId": 1, "occupancy": 0}, |
||||
{"timestamp": 1738000800, "room": "porch", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738000860, "room": "hall", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738000920, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738000980, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1738002000, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738004400, "room": "livingroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738004460, "room": "livingroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738008000, "room": "livingroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738011600, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738011660, "room": "pillbox", "nodeId": 1, "onOff": true}, |
||||
{"timestamp": 1738012200, "room": "bedroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738022400, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738022460, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1738023600, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738024800, "room": "livingroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738024860, "room": "livingroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738028400, "room": "livingroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738032000, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738032060, "room": "pillbox", "nodeId": 1, "onOff": true}, |
||||
{"timestamp": 1738032600, "room": "bedroom", "nodeId": 2, "onOff": false} |
||||
], |
||||
"result": "normal", |
||||
"reason": "The data shows a typical day with all expected activities occurring at regular times." |
||||
}, |
||||
{ |
||||
"input": [ |
||||
{"timestamp": 1738065600, "room": "pillbox", "nodeId": 1, "onOff": true}, |
||||
{"timestamp": 1738065660, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738065900, "room": "bathroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738066200, "room": "bathroom", "nodeId": 3, "humidity": 7500}, |
||||
{"timestamp": 1738066500, "room": "bathroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738066800, "room": "bathroom", "nodeId": 3, "humidity": 7500}, |
||||
{"timestamp": 1738067100, "room": "bathroom", "nodeId": 3, "humidity": 7500}, |
||||
{"timestamp": 1738067400, "room": "bathroom", "nodeId": 3, "humidity": 7500}, |
||||
{"timestamp": 1738067700, "room": "bathroom", "nodeId": 3, "humidity": 7500}, |
||||
{"timestamp": 1738068000, "room": "bathroom", "nodeId": 3, "humidity": 7500}, |
||||
{"timestamp": 1738068300, "room": "bathroom", "nodeId": 3, "humidity": 7500}, |
||||
{"timestamp": 1738068600, "room": "bathroom", "nodeId": 3, "humidity": 7500}, |
||||
{"timestamp": 1738068900, "room": "bathroom", "nodeId": 3, "humidity": 7500}, |
||||
{"timestamp": 1738069200, "room": "bathroom", "nodeId": 3, "humidity": 7500}, |
||||
{"timestamp": 1738069500, "room": "bathroom", "nodeId": 3, "humidity": 7500} |
||||
], |
||||
"result": "anomalous", |
||||
"reason": "High humidity persists in the bathroom with no movement or room transitions for over 45 minutes, suggesting a potential fall during shower." |
||||
}, |
||||
{ |
||||
"input": [ |
||||
{"timestamp": 1738152000, "room": "pillbox", "nodeId": 1, "onOff": true}, |
||||
{"timestamp": 1738152060, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738152300, "room": "bathroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738152600, "room": "bathroom", "nodeId": 3, "humidity": 6500}, |
||||
{"timestamp": 1738152900, "room": "bathroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738153200, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738153260, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1738153800, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738154100, "room": "livingroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738154400, "room": "livingroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738155600, "room": "livingroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738156800, "room": "hall", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738157400, "room": "porch", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738157460, "room": "hall", "nodeId": 1, "occupancy": 0}, |
||||
{"timestamp": 1738173600, "room": "porch", "nodeId": 1, "occupancy": 0}, |
||||
{"timestamp": 1738184400, "room": "porch", "nodeId": 1, "occupancy": 0}, |
||||
{"timestamp": 1738195200, "room": "porch", "nodeId": 1, "occupancy": 0}, |
||||
{"timestamp": 1738206000, "room": "porch", "nodeId": 1, "occupancy": 0} |
||||
], |
||||
"result": "anomalous", |
||||
"reason": "Person left home in the morning but did not return, missing all subsequent daily activities including medications and meals." |
||||
}, |
||||
{ |
||||
"input": [ |
||||
{"timestamp": 1738238400, "room": "pillbox", "nodeId": 1, "onOff": true}, |
||||
{"timestamp": 1738238460, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738238700, "room": "bathroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738239000, "room": "bathroom", "nodeId": 3, "humidity": 6500}, |
||||
{"timestamp": 1738239300, "room": "bathroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738239600, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738239660, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1738240200, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738240500, "room": "livingroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738240800, "room": "livingroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738242000, "room": "livingroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738243200, "room": "hall", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738243800, "room": "porch", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738243860, "room": "hall", "nodeId": 1, "occupancy": 0}, |
||||
{"timestamp": 1738260000, "room": "porch", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738260060, "room": "hall", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738260120, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738260180, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1738261200, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738263600, "room": "livingroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738263660, "room": "livingroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738267200, "room": "livingroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738270800, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738270860, "room": "pillbox", "nodeId": 1, "onOff": true}, |
||||
{"timestamp": 1738271400, "room": "bedroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738281600, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738281660, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1738282800, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738284000, "room": "livingroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738284060, "room": "livingroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738287600, "room": "livingroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738291200, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738291260, "room": "pillbox", "nodeId": 1, "onOff": true}, |
||||
{"timestamp": 1738291800, "room": "bedroom", "nodeId": 2, "onOff": false} |
||||
], |
||||
"result": "normal", |
||||
"reason": "All activities follow the expected pattern with normal timing and sequence." |
||||
}, |
||||
{ |
||||
"input": [ |
||||
{"timestamp": 1738324800, "room": "pillbox", "nodeId": 1, "onOff": true}, |
||||
{"timestamp": 1738324860, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738325100, "room": "bathroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738325400, "room": "bathroom", "nodeId": 3, "humidity": 6500}, |
||||
{"timestamp": 1738325700, "room": "bathroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738326000, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738326600, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738326900, "room": "livingroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738327200, "room": "livingroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738328400, "room": "livingroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738329600, "room": "hall", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738330200, "room": "porch", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738330260, "room": "hall", "nodeId": 1, "occupancy": 0}, |
||||
{"timestamp": 1738346400, "room": "porch", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738346460, "room": "hall", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738346520, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738347600, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738350000, "room": "livingroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738350060, "room": "livingroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738353600, "room": "livingroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738357200, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738357260, "room": "pillbox", "nodeId": 1, "onOff": true}, |
||||
{"timestamp": 1738357800, "room": "bedroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738368000, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738369200, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738370400, "room": "livingroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738370460, "room": "livingroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738374000, "room": "livingroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738377600, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738377660, "room": "pillbox", "nodeId": 1, "onOff": true}, |
||||
{"timestamp": 1738378200, "room": "bedroom", "nodeId": 2, "onOff": false} |
||||
], |
||||
"result": "anomalous", |
||||
"reason": "No fridge activity detected throughout the entire day despite multiple kitchen visits, suggesting potential eating issues or forgetfulness." |
||||
}, |
||||
{ |
||||
"input": [ |
||||
{"timestamp": 1738411200, "room": "pillbox", "nodeId": 1, "onOff": true}, |
||||
{"timestamp": 1738411260, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738411500, "room": "bathroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738411800, "room": "bathroom", "nodeId": 3, "humidity": 6500}, |
||||
{"timestamp": 1738412100, "room": "bathroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738412400, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738412460, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1738413000, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738413300, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738413600, "room": "bedroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738417200, "room": "bedroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738420800, "room": "bedroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738424400, "room": "bedroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738428000, "room": "bedroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738431600, "room": "bedroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738435200, "room": "bedroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738438800, "room": "bedroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738442400, "room": "bedroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738446000, "room": "bedroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738449600, "room": "bedroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738453200, "room": "bedroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738456800, "room": "bedroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738460400, "room": "bedroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738464000, "room": "bedroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738467600, "room": "bedroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738471200, "room": "bedroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738474800, "room": "bedroom", "nodeId": 1, "occupancy": 1} |
||||
], |
||||
"result": "anomalous", |
||||
"reason": "Person remains in bedroom all day after breakfast, missing meals, medications, and normal daily activities. This could indicate illness or other health issues." |
||||
}, |
||||
{ |
||||
"input": [ |
||||
{"timestamp": 1738497600, "room": "pillbox", "nodeId": 1, "onOff": true}, |
||||
{"timestamp": 1738497660, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738497900, "room": "bathroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738498200, "room": "bathroom", "nodeId": 3, "humidity": 6500}, |
||||
{"timestamp": 1738498500, "room": "bathroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738498800, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738498860, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1738499400, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738499700, "room": "livingroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738500000, "room": "livingroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738501200, "room": "livingroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738502400, "room": "hall", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738503000, "room": "porch", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738503060, "room": "hall", "nodeId": 1, "occupancy": 0}, |
||||
{"timestamp": 1738519200, "room": "porch", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738519260, "room": "hall", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738519320, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738519380, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1738520400, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738522800, "room": "livingroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738522860, "room": "livingroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738526400, "room": "livingroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738530000, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738530060, "room": "pillbox", "nodeId": 1, "onOff": true}, |
||||
{"timestamp": 1738530600, "room": "bedroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738540800, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738540860, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1738542000, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738543200, "room": "livingroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738543260, "room": "livingroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738546800, "room": "livingroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738550400, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738550460, "room": "pillbox", "nodeId": 1, "onOff": true}, |
||||
{"timestamp": 1738551000, "room": "bedroom", "nodeId": 2, "onOff": false} |
||||
], |
||||
"result": "normal", |
||||
"reason": "All activities follow the expected daily routine with normal timing and sequence." |
||||
}, |
||||
{ |
||||
"input": [ |
||||
{"timestamp": 1738584000, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738584300, "room": "bathroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738584600, "room": "bathroom", "nodeId": 3, "humidity": 6500}, |
||||
{"timestamp": 1738584900, "room": "bathroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738585200, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738585260, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1738585800, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738586100, "room": "livingroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738586400, "room": "livingroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738587600, "room": "livingroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738588800, "room": "hall", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738589400, "room": "porch", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738589460, "room": "hall", "nodeId": 1, "occupancy": 0}, |
||||
{"timestamp": 1738605600, "room": "porch", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738605660, "room": "hall", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738605720, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738605780, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1738606800, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738609200, "room": "livingroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738609260, "room": "livingroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738612800, "room": "livingroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738616400, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738617000, "room": "bedroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738627200, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738627260, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1738628400, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738629600, "room": "livingroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738629660, "room": "livingroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738633200, "room": "livingroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738636800, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738637400, "room": "bedroom", "nodeId": 2, "onOff": false} |
||||
], |
||||
"result": "anomalous", |
||||
"reason": "All three daily medications were missed (morning, afternoon, and evening), while other activities remained normal. This suggests a serious deviation in medication adherence." |
||||
}, |
||||
{ |
||||
"input": [ |
||||
{"timestamp": 1738670400, "room": "pillbox", "nodeId": 1, "onOff": true}, |
||||
{"timestamp": 1738670460, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738670700, "room": "bathroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738671000, "room": "bathroom", "nodeId": 3, "humidity": 6500}, |
||||
{"timestamp": 1738671300, "room": "bathroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738671600, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738671660, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1738672200, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738672500, "room": "livingroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738672800, "room": "livingroom", "nodeId": 1, "occupancy": 0}, |
||||
{"timestamp": 1738672860, "room": "kitchen", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738672920, "room": "hall", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738672980, "room": "bathroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738673040, "room": "bedroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738673100, "room": "livingroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738673160, "room": "kitchen", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738673220, "room": "hall", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738673280, "room": "bathroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738673340, "room": "bedroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738673400, "room": "livingroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738673460, "room": "kitchen", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738673520, "room": "hall", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738673580, "room": "bathroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738673640, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738673700, "room": "bedroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738674000, "room": "bedroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738677600, "room": "bedroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738681200, "room": "bedroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738684800, "room": "bedroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738688400, "room": "bedroom", "nodeId": 1, "occupancy": 1} |
||||
], |
||||
"result": "anomalous", |
||||
"reason": "Unusual rapid transitions between rooms followed by extended bedroom stay suggests potential confusion or disorientation. Missing subsequent daily activities and medications adds to the concern." |
||||
}, |
||||
{ |
||||
"input": [ |
||||
{"timestamp": 1738756800, "room": "pillbox", "nodeId": 1, "onOff": true}, |
||||
{"timestamp": 1738756860, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738757100, "room": "bathroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738757400, "room": "bathroom", "nodeId": 3, "humidity": 6500}, |
||||
{"timestamp": 1738757700, "room": "bathroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738758000, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738758060, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1738758600, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738758900, "room": "livingroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738759200, "room": "livingroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738760400, "room": "livingroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738761600, "room": "hall", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738762200, "room": "porch", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738762260, "room": "hall", "nodeId": 1, "occupancy": 0}, |
||||
{"timestamp": 1738778400, "room": "porch", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738778460, "room": "hall", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738778520, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738778580, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1738779600, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738782000, "room": "livingroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738782060, "room": "livingroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738785600, "room": "livingroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738789200, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738789260, "room": "pillbox", "nodeId": 1, "onOff": true}, |
||||
{"timestamp": 1738789800, "room": "bedroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738800000, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738800060, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1738801200, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738802400, "room": "livingroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738802460, "room": "livingroom", "nodeId": 1, "occupancy": 1}, |
||||
{"timestamp": 1738806000, "room": "livingroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738809600, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738809660, "room": "pillbox", "nodeId": 1, "onOff": true}, |
||||
{"timestamp": 1738810200, "room": "bedroom", "nodeId": 2, "onOff": false} |
||||
], |
||||
"result": "normal", |
||||
"reason": "All activities follow the expected daily routine with normal timing and sequence." |
||||
}, |
||||
{ |
||||
"input": [ |
||||
{"timestamp": 1738843200, "room": "pillbox", "nodeId": 1, "onOff": true}, |
||||
{"timestamp": 1738843260, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738843500, "room": "bathroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738843800, "room": "bathroom", "nodeId": 3, "humidity": 6500}, |
||||
{"timestamp": 1738844100, "room": "bathroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738844400, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738844460, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1738844520, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738844580, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738844640, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1738844700, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738844760, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738844820, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1738844880, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738844940, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738845000, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1738845060, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738866400, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738866460, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1738866520, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738866580, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738866640, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1738866700, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738875600, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738875660, "room": "pillbox", "nodeId": 1, "onOff": true}, |
||||
{"timestamp": 1738876200, "room": "bedroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738888400, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738888460, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1738888520, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738888580, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738888640, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1738888700, "room": "kitchen", "nodeId": 2, "onOff": false} |
||||
], |
||||
"result": "anomalous", |
||||
"reason": "Unusually frequent kitchen visits and fridge openings throughout the day suggest potential memory issues or compulsive behavior. While other activities remain normal, the repeated kitchen pattern is concerning." |
||||
}, |
||||
{ |
||||
"input": [ |
||||
{"timestamp": 1738929600, "room": "pillbox", "nodeId": 1, "onOff": true}, |
||||
{"timestamp": 1738929660, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738929900, "room": "bathroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738930200, "room": "bathroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738930260, "room": "bathroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738930320, "room": "bathroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738930380, "room": "bathroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738930440, "room": "bathroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738930500, "room": "bathroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738930560, "room": "bathroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738944000, "room": "bathroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738944060, "room": "bathroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738944120, "room": "bathroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738944180, "room": "bathroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738952400, "room": "kitchen", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738952460, "room": "kitchen", "event": "fridge_opened"}, |
||||
{"timestamp": 1738953000, "room": "kitchen", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738957600, "room": "bathroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738957660, "room": "bathroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738957720, "room": "bathroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738957780, "room": "bathroom", "nodeId": 2, "onOff": false}, |
||||
{"timestamp": 1738962000, "room": "bedroom", "nodeId": 2, "onOff": true}, |
||||
{"timestamp": 1738962060, "room": "pillbox", "nodeId": 1, "onOff": true}, |
||||
{"timestamp": 1738962600, "room": "bedroom", "nodeId": 2, "onOff": false} |
||||
], |
||||
"result": "anomalous", |
||||
"reason": "Unusually frequent bathroom visits throughout the day, with multiple entries and exits in short succession. While other activities remain normal, this pattern suggests potential health issues requiring attention." |
||||
} |
||||
] |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,83 @@
|
||||
from typing import Optional |
||||
from transformers import AutoTokenizer |
||||
import re |
||||
import json |
||||
|
||||
BASE_MODEL = "meta-llama/Meta-Llama-3.1-8B" |
||||
|
||||
MIN_TOKENS = 150 # Any less than this, and we don't have enough useful content |
||||
MAX_TOKENS = 160 # Truncate after this many tokens. Then after adding in prompt text, we will get to around 180 tokens |
||||
|
||||
MIN_CHARS = 300 |
||||
CEILING_CHARS = MAX_TOKENS * 7 |
||||
|
||||
class Item: |
||||
""" |
||||
An Item is a cleaned, curated datapoint of a Product with a Price |
||||
""" |
||||
|
||||
tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL, trust_remote_code=True) |
||||
PREFIX = "Result is " |
||||
QUESTION = "How would you classify this sensor data - normal or anomalous?" |
||||
REMOVALS = ['"event": "car_opened"'] |
||||
|
||||
result: str |
||||
category: str |
||||
token_count: int = 0 |
||||
details: Optional[str] |
||||
prompt: Optional[str] = None |
||||
include = False |
||||
|
||||
def __init__(self, data, result): |
||||
self.result = result |
||||
self.parse(data) |
||||
|
||||
def scrub(self, stuff): |
||||
""" |
||||
Clean up the provided text by removing unnecessary characters and whitespace |
||||
""" |
||||
return stuff |
||||
|
||||
def parse(self, data): |
||||
""" |
||||
Parse this datapoint and if it fits within the allowed Token range, |
||||
then set include to True |
||||
""" |
||||
contents = json.dumps(data['input']) |
||||
if contents: |
||||
contents += '\n' |
||||
self.details = contents |
||||
if len(contents) > MIN_CHARS: |
||||
contents = contents[:CEILING_CHARS] |
||||
text = f"{self.scrub(contents)}" |
||||
tokens = self.tokenizer.encode(text, add_special_tokens=False) |
||||
if len(tokens) > MIN_TOKENS: |
||||
tokens = tokens[:MAX_TOKENS] |
||||
text = self.tokenizer.decode(tokens) |
||||
self.make_prompt(text) |
||||
self.include = True |
||||
|
||||
def make_prompt(self, text): |
||||
""" |
||||
Set the prompt instance variable to be a prompt appropriate for training |
||||
""" |
||||
self.prompt = f"{self.QUESTION}\n\n{text}\n\n" |
||||
self.prompt += f"{self.PREFIX}{self.result}" |
||||
self.token_count = len(self.tokenizer.encode(self.prompt, add_special_tokens=False)) |
||||
|
||||
def test_prompt(self): |
||||
""" |
||||
Return a prompt suitable for testing, with the actual price removed |
||||
""" |
||||
return self.prompt.split(self.PREFIX)[0] + self.PREFIX |
||||
|
||||
def __repr__(self): |
||||
""" |
||||
Return a String version of this Item |
||||
""" |
||||
return f"<${self.result}>" |
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,102 @@
|
||||
# imports |
||||
|
||||
import os |
||||
from dotenv import load_dotenv |
||||
from huggingface_hub import login |
||||
from datasets import load_dataset, Dataset, DatasetDict |
||||
import matplotlib.pyplot as plt |
||||
import json |
||||
|
||||
# environment |
||||
|
||||
load_dotenv() |
||||
os.environ['OPENAI_API_KEY'] = os.getenv('OPENAI_API_KEY', 'your-key-if-not-using-env') |
||||
os.environ['ANTHROPIC_API_KEY'] = os.getenv('ANTHROPIC_API_KEY', 'your-key-if-not-using-env') |
||||
os.environ['HF_TOKEN'] = os.getenv('HF_TOKEN', 'your-key-if-not-using-env') |
||||
|
||||
# Log in to HuggingFace |
||||
|
||||
hf_token = os.environ['HF_TOKEN'] |
||||
login(hf_token, add_to_git_credential=True) |
||||
|
||||
# One more import - the Item class |
||||
# If you get an error that you need to agree to Meta's terms when you run this, then follow the link it provides you and follow their instructions |
||||
# You should get approved by Meta within minutes |
||||
# Any problems - message me or email me! |
||||
|
||||
from items import Item |
||||
|
||||
# Load in our dataset |
||||
# Open and read the JSON file |
||||
with open('/home/ivob/Projects/llm_engineering/project/data/training_data.json', 'r') as file: |
||||
dataset = json.load(file) |
||||
|
||||
# Print the data |
||||
print(dataset) |
||||
|
||||
print(f"Number of Situations: {len(dataset):,}") |
||||
|
||||
# Investigate a particular datapoint |
||||
datapoint = dataset[2] |
||||
|
||||
# Investigate |
||||
|
||||
print(datapoint["input"]) |
||||
print(datapoint["result"]) |
||||
print(datapoint["reason"]) |
||||
|
||||
|
||||
# Plot the distribution of results |
||||
|
||||
# Count the occurrences of "normal" and "anomalous" results |
||||
situation_counts = {"normal": 0, "anomalous": 0} |
||||
for entry in dataset: |
||||
result = entry.get("result", "unknown").lower() |
||||
if result in situation_counts: |
||||
situation_counts[result] += 1 |
||||
|
||||
# Extract keys and values for the bar chart |
||||
labels = list(situation_counts.keys()) |
||||
counts = list(situation_counts.values()) |
||||
|
||||
# Plot the bar chart |
||||
plt.figure(figsize=(8, 6)) |
||||
plt.bar(labels, counts, color=['green', 'red'], alpha=0.7) |
||||
|
||||
# Add labels and title |
||||
plt.xlabel("Situation Type", fontsize=12) |
||||
plt.ylabel("Count", fontsize=12) |
||||
plt.title("Number of Normal vs Anomalous Situations", fontsize=14) |
||||
|
||||
# Annotate bars with counts |
||||
for i, count in enumerate(counts): |
||||
plt.text(i, count + 0.2, str(count), ha='center', fontsize=10) |
||||
|
||||
# Display the plot |
||||
plt.tight_layout() |
||||
plt.show() |
||||
|
||||
# So what are the anomalous items?? |
||||
|
||||
for datapoint in dataset: |
||||
try: |
||||
result = datapoint["result"] |
||||
if result == "anomalous": |
||||
print(datapoint['input']) |
||||
except ValueError as e: |
||||
pass |
||||
|
||||
# Create an Item object for each with a result |
||||
|
||||
items = [] |
||||
for datapoint in dataset: |
||||
try: |
||||
result = datapoint["result"] |
||||
if result == 'normal' or result == 'anomalous': |
||||
item = Item(datapoint, result) |
||||
if item.include: |
||||
items.append(item) |
||||
except ValueError as e: |
||||
pass |
||||
|
||||
print(f"There are {len(items):,} items") |
@ -0,0 +1,97 @@
|
||||
import math |
||||
import matplotlib.pyplot as plt |
||||
|
||||
GREEN = "\033[92m" |
||||
YELLOW = "\033[93m" |
||||
RED = "\033[91m" |
||||
RESET = "\033[0m" |
||||
COLOR_MAP = {"red":RED, "orange": YELLOW, "green": GREEN} |
||||
|
||||
class Tester: |
||||
|
||||
def __init__(self, predictor, data, title=None, size=250): |
||||
self.predictor = predictor |
||||
self.data = data |
||||
self.title = title or predictor.__name__.replace("_", " ").title() |
||||
self.size = size |
||||
self.guesses = [] |
||||
self.truths = [] |
||||
self.errors = [] |
||||
self.colors = [] |
||||
|
||||
def color_for(self, error, truth): |
||||
if error == truth: |
||||
return "green" |
||||
else: |
||||
return "red" |
||||
|
||||
def run_datapoint(self, i): |
||||
datapoint = self.data[i] |
||||
guess = self.predictor(datapoint) |
||||
truth = datapoint.price |
||||
error = guess == truth |
||||
color = self.color_for(error, truth) |
||||
title = datapoint.title if len(datapoint.title) <= 40 else datapoint.title[:40]+"..." |
||||
self.guesses.append(guess) |
||||
self.truths.append(truth) |
||||
self.errors.append(error) |
||||
self.colors.append(color) |
||||
print(f"{COLOR_MAP[color]}{i+1}: Guess: ${guess:,.2f} Truth: ${truth:,.2f} Error: ${error:,.2f} SLE: {sle:,.2f} Item: {title}{RESET}") |
||||
|
||||
def chart(self, title): |
||||
actual = self.truths |
||||
predicted = self.guesses |
||||
|
||||
# Get unique classes |
||||
classes = list(set(actual + predicted)) # Union of unique classes in actual and predicted |
||||
|
||||
# Initialize the confusion matrix as a dictionary |
||||
confusion_matrix = {true: {pred: 0 for pred in classes} for true in classes} |
||||
|
||||
# Populate the confusion matrix |
||||
for a, p in zip(actual, predicted): |
||||
confusion_matrix[a][p] += 1 |
||||
|
||||
# Convert the confusion matrix into a 2D list for visualization |
||||
matrix = [[confusion_matrix[true][pred] for pred in classes] for true in classes] |
||||
|
||||
# Plot the confusion matrix |
||||
plt.figure(figsize=(8, 6)) |
||||
plt.imshow(matrix, interpolation='nearest', cmap=plt.cm.Blues) |
||||
plt.title(title) |
||||
plt.colorbar() |
||||
|
||||
# Add labels |
||||
tick_marks = range(len(classes)) |
||||
plt.xticks(tick_marks, classes) |
||||
plt.yticks(tick_marks, classes) |
||||
plt.ylabel('Actual Label') |
||||
plt.xlabel('Predicted Label') |
||||
|
||||
# Add text annotations |
||||
for i in range(len(classes)): |
||||
for j in range(len(classes)): |
||||
plt.text(j, i, matrix[i][j], |
||||
horizontalalignment="center", |
||||
color="white" if matrix[i][j] > max(max(row) for row in matrix) / 2 else "black") |
||||
|
||||
plt.tight_layout() |
||||
plt.show() |
||||
|
||||
|
||||
def report(self): |
||||
average_error = sum(self.errors) / self.size |
||||
rmsle = math.sqrt(sum(self.sles) / self.size) |
||||
hits = sum(1 for color in self.colors if color=="green") |
||||
title = f"{self.title} Error=${average_error:,.2f} RMSLE={rmsle:,.2f} Hits={hits/self.size*100:.1f}%" |
||||
self.chart(title) |
||||
|
||||
def run(self): |
||||
self.error = 0 |
||||
for i in range(self.size): |
||||
self.run_datapoint(i) |
||||
self.report() |
||||
|
||||
@classmethod |
||||
def test(cls, function, data): |
||||
cls(function, data).run() |
@ -0,0 +1,71 @@
|
||||
import json |
||||
import time |
||||
|
||||
# Usage |
||||
input_file = '/home/ivob/Projects/llm_engineering/project/data/raw_data.json' |
||||
output_file = '/home/ivob/Projects/llm_engineering/project/data/transformed_data.json' |
||||
|
||||
events = [] |
||||
|
||||
def read_events(): |
||||
with open(input_file, 'r') as f: |
||||
events = [json.loads(line) for line in f] |
||||
return events |
||||
|
||||
def transform_event(event, base_timestamp=None): |
||||
if base_timestamp is None: |
||||
base_timestamp = int(time.time()) |
||||
|
||||
if 'data' in event: |
||||
#only run if array |
||||
if isinstance(event['data'], list): |
||||
# Extract node ID, which is the first element in the data list |
||||
node_id = event['data'][0] |
||||
|
||||
# Extract the specific attribute and its value |
||||
attribute_data = event['data'][1] |
||||
attribute_id = list(attribute_data.keys())[0] |
||||
attribute_type = list(attribute_data[attribute_id].keys())[0] |
||||
|
||||
# Determine the value based on attribute type |
||||
if attribute_type == 'TemperatureMeasurement': |
||||
value = attribute_data[attribute_id][attribute_type]['MeasuredValue'] |
||||
elif attribute_type == 'RelativeHumidityMeasurement': |
||||
value = attribute_data[attribute_id][attribute_type]['MeasuredValue'] |
||||
elif attribute_type == 'OnOff': |
||||
value = attribute_data[attribute_id][attribute_type]['OnOff'] |
||||
elif attribute_type == 'OccupancySensing': |
||||
value = attribute_data[attribute_id][attribute_type]['Occupancy'] |
||||
else: |
||||
value = None |
||||
|
||||
# Generate output dictionary |
||||
output = { |
||||
'timestamp': base_timestamp + (hash(json.dumps(event)) % 1000), |
||||
'room': 'kitchen', |
||||
'nodeId': node_id |
||||
} |
||||
|
||||
# Add specific attribute to output |
||||
if attribute_type == 'TemperatureMeasurement': |
||||
output['temperature'] = value |
||||
elif attribute_type == 'RelativeHumidityMeasurement': |
||||
output['humidity'] = value |
||||
elif attribute_type == 'OnOff': |
||||
output['onOff'] = value |
||||
elif attribute_type == 'OccupancySensing': |
||||
output['occupancy'] = value |
||||
else: |
||||
output = None |
||||
else: |
||||
output = None |
||||
|
||||
return output |
||||
|
||||
# Sample usage |
||||
events = read_events() |
||||
|
||||
transformed_events = [transform_event(event) for event in events] |
||||
for event in transformed_events: |
||||
if event is not None: |
||||
print(json.dumps(event)) |
@ -0,0 +1,77 @@
|
||||
import random |
||||
import json |
||||
from datetime import datetime, timedelta |
||||
|
||||
def generate_iot_data(num_entries=100): |
||||
rooms = ['livingroom', 'hall', 'bedroom', 'bathroom', 'kitchen', 'garage', 'study'] |
||||
node_ids = [1, 2, 3] |
||||
custom_events = [ |
||||
{"type": "fridge_opened", "room": "kitchen"}, |
||||
{"type": "kitchen_light", "room": "kitchen"}, |
||||
{"type": "pillbox_opened", "room": "bedroom"} |
||||
] |
||||
|
||||
base_timestamp = int(datetime.now().timestamp()) |
||||
data_entries = [] |
||||
|
||||
for _ in range(num_entries): |
||||
# Randomly choose between standard sensor data and custom events |
||||
if random.random() < 0.7: # 70% chance of standard sensor data |
||||
room = random.choice(rooms) |
||||
node_id = random.choice(node_ids) |
||||
timestamp = base_timestamp - random.randint(0, 3600) |
||||
|
||||
entry_type = random.choice(['temperature', 'occupancy', 'onOff', 'humidity']) |
||||
|
||||
if entry_type == 'temperature': |
||||
value = random.randint(1500, 3000) |
||||
entry = { |
||||
"timestamp": timestamp, |
||||
"room": room, |
||||
"nodeId": node_id, |
||||
"temperature": value |
||||
} |
||||
elif entry_type == 'occupancy': |
||||
value = random.randint(0, 1) |
||||
entry = { |
||||
"timestamp": timestamp, |
||||
"room": room, |
||||
"nodeId": node_id, |
||||
"occupancy": value |
||||
} |
||||
elif entry_type == 'onOff': |
||||
value = random.choice([True, False]) |
||||
entry = { |
||||
"timestamp": timestamp, |
||||
"room": room, |
||||
"nodeId": node_id, |
||||
"onOff": value |
||||
} |
||||
elif entry_type == 'humidity': |
||||
value = random.randint(3000, 7000) |
||||
entry = { |
||||
"timestamp": timestamp, |
||||
"room": room, |
||||
"nodeId": node_id, |
||||
"humidity": value |
||||
} |
||||
else: # 30% chance of custom event |
||||
event = random.choice(custom_events) |
||||
timestamp = base_timestamp - random.randint(0, 3600) |
||||
|
||||
entry = { |
||||
"timestamp": timestamp, |
||||
"room": event["room"], |
||||
"event": event["type"] |
||||
} |
||||
|
||||
data_entries.append(entry) |
||||
|
||||
return data_entries |
||||
|
||||
# Generate data |
||||
iot_data = generate_iot_data(100) |
||||
|
||||
# Print as JSON |
||||
for entry in iot_data: |
||||
print(json.dumps(entry)) |
Loading…
Reference in new issue