Activity Recognition Through Complex
Event Processing: First Findings
Sylvain Hallé, Sébastien Gaboury
and Bruno Bouchard
Université du Québec à Chicoutimi, Canada
February 12th, 2016
IMPOSTOR WARNING
1. ...
2. ...
3. ...
1. ...
2. ...
3. ...
X
1. ...
2. ...
3. ...
X
. . .
. . .
Time
Power
Peak
Plateau
0
200
400
600
800
1000
1200
8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754
S.WL2
S.WL1
T.x
Example: Blender
SS-PL3>-393
| FFT-L2-6<=-3
| | SS-PL2<=1071: ToasterON
| | SS-PL2>1071: ElectricKettleON
| FFT-L2-6>-3
| | FFT-L2-6<=9
| | | SS-PL1 <=148
| | | | SS-QL1<=-169: RangeHoodFanOFF
| | | | SS-QL1>-169
| | | | | SS-QL1<=135
| | | | | | SS-PL1<=-788: CoffeeMakerOff
| | | | | |
| | | | | | SS-PL1>-788
| | | | | | | FFT-L1-1<=-788:
| | | | | | | CoffeeMakerOFF
| | | | | | | FFT-L1-1>-408
| | | | | | | | FFT-L1-5 <=153:MixerOff
| | | | | | | | FFT-L1-5->153
...
(Maitre et al. 2013)
SS-PL3>-393
| FFT-L2-6<=-3
| | SS-PL2<=1071: ToasterON
| | SS-PL2>1071: ElectricKettleON
| FFT-L2-6>-3
| | FFT-L2-6<=9
| | | SS-PL1 <=148
| | | | SS-QL1<=-169: RangeHoodFanOFF
| | | | SS-QL1>-169
| | | | | SS-QL1<=135
| | | | | | SS-PL1<=-788: CoffeeMakerOff
| | | | | |
| | | | | | SS-PL1>-788
| | | | | | | FFT-L1-1<=-788:
| | | | | | | CoffeeMakerOFF
| | | | | | | FFT-L1-1>-408
| | | | | | | | FFT-L1-5 <=153:MixerOff
| | | | | | | | FFT-L1-5->153
...
(Maitre et al. 2013)
How do you isolate a single device?
How do you add a new device?
How do you adjust noise thresholds?
How do you reuse that output?
Alan Perlis
(1922-1990)
Beware of of the
Turing tar-pit in
which everything is
possible but nothing
of interest is easy. ,,
,,
OI I . . .
BREAKFAST
Signal processing
Finite-state machines
?
C
E
P
omplex
vent
rocessing
A declarative event stream
query engine
Booleans
B
Numbers
R
2
3
4
π
Strings
S
abc
Functions
X Y→
Sets
X
2
A processor is a function that takes 0 or more
event traces as input, and returns 0 or 1
event trace as output
. . . . . .
Processors can be composed: the output of
a processor can be given as the input of
another ("piping")
BeepBeep is an event stream query engine
that provides...
A set of basic processors (independent from
any event type)
A core grammar and interpreter to
compose ("pipe") processors
Mechanisms to extend the grammar
with user-defined events, processors, etc.
abc. . . a . . .
n c
Ψ
abc. . . b . . .
n c
EVERY nTH OF (T)
TRIM n FROM (T)
WHERE2 1 5 0 2 0
C
C2 1 5 0
(T) WHERE condition
COMBINE (T) WITH f
Σ+2 1 5 0 2 3 8
f
f
8
2 1 5 0 2 1 5 0
f1 5 0 1 5 0
f5 0 5 0
++
+
a . . .b
a . . .b
FILE "filename"
SAVE (T) TO "filename"
On every fifth trading day starting today,
calculate the average closing price of MSFT
for the five most recent trading days, and keep
the query standing for fifty trading days.
timestamp stockSymbol closingPrice
0 APPL 1039.3
0 MSFT 950.0
0 GOGL 433.3
1 MSFT 951.2
1 APPL 1038.3
... ... ...
On every fifth trading day starting today,
calculate the average closing price of MSFT
for the five most recent trading days, and keep
the query standing for fifty trading days.
String line = br.readLine().trim();
if (!line.isEmpty()) {
String[] parts = line.split(",");
if (parts[0].compareTo("ABC") != 0) {
value_index++;
sum += Double.parseDouble(parts[1]);
if (value_index == 5) {
double average = sum / 5;
value_index = 0;
sum = 0;
return average;
}}}
On every fifth trading day starting today,
calculate the average closing price of MSFT
for the five most recent trading days, and keep
the query standing for fifty trading days.
SELECT afd FROM (
SELECT S1.timestamp AS ts,
AVG(S2.closingPrice) AS afd
FROM
(SELECT * FROM stocks
WHERE stockSymbol = "MSFT") AS S1,
(SELECT * FROM stocks
WHERE stockSymbol = "MSFT") AS S2
WHERE (S2.timestamp - S1.timestamp) < 5
GROUP BY S1.timestamp) AS S3
WHERE MOD(ts, 5) = 0;
On every fifth trading day starting today,
calculate the average closing price of MSFT
for the five most recent trading days, and keep
the query standing for fifty trading days.
EVERY 5TH OF (
APPLY (THE AVERAGE OF (*)) TO (
SELECT closingPrice FROM stocks)
WHERE (stockSymbol) = ("MSFT"))))
ON A WINDOW OF 5).
*
10*
100
>
10*
100
>
0
10*
100
>
0
0
>
0
10
10*
10
100 10
WL1
700
200
200
I
*
*
O
700
*200
*
OI I
It works
1500 Hz performance
Rapid prototyping -400 LOC3
What vs. how
https://liflab.github.io/
beepbeep-3

Activity Recognition Through Complex Event Processing: First Findings

  • 1.
    Activity Recognition ThroughComplex Event Processing: First Findings Sylvain Hallé, Sébastien Gaboury and Bruno Bouchard Université du Québec à Chicoutimi, Canada February 12th, 2016
  • 2.
  • 4.
  • 5.
  • 6.
  • 11.
  • 12.
  • 13.
  • 14.
    0 200 400 600 800 1000 1200 8744 8745 87468747 8748 8749 8750 8751 8752 8753 8754 S.WL2 S.WL1 T.x Example: Blender
  • 15.
    SS-PL3>-393 | FFT-L2-6<=-3 | |SS-PL2<=1071: ToasterON | | SS-PL2>1071: ElectricKettleON | FFT-L2-6>-3 | | FFT-L2-6<=9 | | | SS-PL1 <=148 | | | | SS-QL1<=-169: RangeHoodFanOFF | | | | SS-QL1>-169 | | | | | SS-QL1<=135 | | | | | | SS-PL1<=-788: CoffeeMakerOff | | | | | | | | | | | | SS-PL1>-788 | | | | | | | FFT-L1-1<=-788: | | | | | | | CoffeeMakerOFF | | | | | | | FFT-L1-1>-408 | | | | | | | | FFT-L1-5 <=153:MixerOff | | | | | | | | FFT-L1-5->153 ... (Maitre et al. 2013)
  • 16.
    SS-PL3>-393 | FFT-L2-6<=-3 | |SS-PL2<=1071: ToasterON | | SS-PL2>1071: ElectricKettleON | FFT-L2-6>-3 | | FFT-L2-6<=9 | | | SS-PL1 <=148 | | | | SS-QL1<=-169: RangeHoodFanOFF | | | | SS-QL1>-169 | | | | | SS-QL1<=135 | | | | | | SS-PL1<=-788: CoffeeMakerOff | | | | | | | | | | | | SS-PL1>-788 | | | | | | | FFT-L1-1<=-788: | | | | | | | CoffeeMakerOFF | | | | | | | FFT-L1-1>-408 | | | | | | | | FFT-L1-5 <=153:MixerOff | | | | | | | | FFT-L1-5->153 ... (Maitre et al. 2013) How do you isolate a single device? How do you add a new device? How do you adjust noise thresholds? How do you reuse that output?
  • 17.
    Alan Perlis (1922-1990) Beware ofof the Turing tar-pit in which everything is possible but nothing of interest is easy. ,, ,,
  • 18.
    OI I .. . BREAKFAST Signal processing Finite-state machines ?
  • 19.
  • 20.
    A declarative eventstream query engine
  • 21.
  • 22.
    A processor isa function that takes 0 or more event traces as input, and returns 0 or 1 event trace as output . . . . . .
  • 23.
    Processors can becomposed: the output of a processor can be given as the input of another ("piping")
  • 24.
    BeepBeep is anevent stream query engine that provides... A set of basic processors (independent from any event type) A core grammar and interpreter to compose ("pipe") processors Mechanisms to extend the grammar with user-defined events, processors, etc.
  • 25.
    abc. . .a . . . n c Ψ abc. . . b . . . n c EVERY nTH OF (T) TRIM n FROM (T)
  • 26.
    WHERE2 1 50 2 0 C C2 1 5 0 (T) WHERE condition
  • 27.
    COMBINE (T) WITHf Σ+2 1 5 0 2 3 8 f f 8 2 1 5 0 2 1 5 0 f1 5 0 1 5 0 f5 0 5 0 ++ +
  • 28.
    a . ..b a . . .b FILE "filename" SAVE (T) TO "filename"
  • 29.
    On every fifthtrading day starting today, calculate the average closing price of MSFT for the five most recent trading days, and keep the query standing for fifty trading days. timestamp stockSymbol closingPrice 0 APPL 1039.3 0 MSFT 950.0 0 GOGL 433.3 1 MSFT 951.2 1 APPL 1038.3 ... ... ...
  • 30.
    On every fifthtrading day starting today, calculate the average closing price of MSFT for the five most recent trading days, and keep the query standing for fifty trading days. String line = br.readLine().trim(); if (!line.isEmpty()) { String[] parts = line.split(","); if (parts[0].compareTo("ABC") != 0) { value_index++; sum += Double.parseDouble(parts[1]); if (value_index == 5) { double average = sum / 5; value_index = 0; sum = 0; return average; }}}
  • 31.
    On every fifthtrading day starting today, calculate the average closing price of MSFT for the five most recent trading days, and keep the query standing for fifty trading days. SELECT afd FROM ( SELECT S1.timestamp AS ts, AVG(S2.closingPrice) AS afd FROM (SELECT * FROM stocks WHERE stockSymbol = "MSFT") AS S1, (SELECT * FROM stocks WHERE stockSymbol = "MSFT") AS S2 WHERE (S2.timestamp - S1.timestamp) < 5 GROUP BY S1.timestamp) AS S3 WHERE MOD(ts, 5) = 0;
  • 32.
    On every fifthtrading day starting today, calculate the average closing price of MSFT for the five most recent trading days, and keep the query standing for fifty trading days. EVERY 5TH OF ( APPLY (THE AVERAGE OF (*)) TO ( SELECT closingPrice FROM stocks) WHERE (stockSymbol) = ("MSFT")))) ON A WINDOW OF 5).
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 46.
    It works 1500 Hzperformance Rapid prototyping -400 LOC3 What vs. how https://liflab.github.io/ beepbeep-3