| Algorithm 1 Contextual data extraction algorithm (CDEA) |
| Input: Sensor identities (SAID, SSID, ACTST, ACTET), where SAID is the main activity, SSID is the sub-activity identities, ACTST and ACTET are the activation and deactivation time of SAID (representing a main activity) respectively. |
| Output: Comprehensive training tuple (Time ^ Location ^ ACT ^ S_ACT ^ Dur_ACT → Class) |
| 1: IF (SAID== ON state) |
| 2: IF (SAID == i) |
| 3: Location = Loci ^ Activity = ACTi ^ Object = Obji |
| 4: IF (SSID == j) |
| 5: Sub_Act = S_ACTj |
| 6: IF (SAID == OFF state) |
| 7: Dur_ACTi = |ACTET − ACTST| |
| 8: ELSE Dur_ACTi = undetermined |
| 9: Time = ACTST |
| 10: RETURN Training tuple (TRD) |