3
$\begingroup$

I am collecting data from a sensor over time, and I'm trying to figure out how to detect "events" in the data - specifically, when a given event begins and ends. The frequency, duration, and amplitude of these events varies.

Rather than using some rules-based scheme that proves to be rather ineffective, I want to train a model to detect these events for me. An example of my data (in only one dimension; I have multiple variables that I'm reading) looks like this:

Time series sensor data

There's one event here and some baseline data on either side.

My raw data before and during this event looks like:

1/1/2016 12:48:03   14.2
1/1/2016 12:48:04   12.8
1/1/2016 12:48:05   13.6
1/1/2016 12:48:06   13.5
1/1/2016 12:48:07   12.9
1/1/2016 12:48:08   15
...
1/1/2016 12:48:34   27.7
1/1/2016 12:48:35   30.3
1/1/2016 12:48:36   31
1/1/2016 12:48:37   32.8
1/1/2016 12:48:38   31.1
1/1/2016 12:48:39   28.7
1/1/2016 12:48:40   32.1
...

I have training data consisting of raw readings and timestamps that I can correlate to a truthset of event start and end times, but I don't know how I should go about featurizing to build a model. I assume I would keep a window of, say, 30 seconds or a minute of readings. (Events are typically more than a minute long, but I don't know whether I would need my window to contain the entire event.)

I'm familiar (but not an expert) with regression and boosted trees, and I know of tools that can generate code I can use without third-party libraries. But I don't know whether these are feasible approaches to solving my problem.

How can I go about detecting these events?

Edit: After some discussion, I've created the following graph to show what more data might look like from different signals. The duration of the manually labeled event is in blue (using the right axis labeled 0/1). Three signals show up strongly:

  • Red covers the overall event reasonably well and is essentially the above example
  • Purple-blue has an even stronger signal but only for the first half or so of the event
  • Yellow-green has a stronger signal than reed for maybe a third of the event, but basically after purple-blue dies off.

Some signals (eg, the bottom-most orange on the left side) have an increase during the event. These either have a weak signal that should be captured or have no signal; however, it's not obvious whether any correlations between these signals and events exist, and if so, how to extract them.

Multi-signal input

$\endgroup$
  • $\begingroup$ I am not sure what is your objective. Detecting event when it starts and ends? While reading or after the measurements are done? Some moving average or derivative grows fast for this event, if you have a baseline (something like mean) without event points for thresholding it makes the job done. The moving average should be a bit wider than possible fluctuations (like ~12:49:45) to avoid triggering false positive. $\endgroup$ – Evil Jul 30 '16 at 20:40
  • $\begingroup$ Yes, I'm trying to figure out when the events start and end. At a minimum, after the fact. Realtime would be nice, but not necessary. I can get a rough idea of a baseline, but eventually, my hope is to be able to detect different kinds of events from different sensors, which each may have a different baseline and signature for their events. $\endgroup$ – FetchLaVache Jul 30 '16 at 22:27
  • $\begingroup$ Could you give some broader context? Is the characteristic of events repeatable? Are sensors detecting the same event or unreleated? Baselines are different among the sensors, but taking one sensor could you estimate baseline? And the most important part - you want to have some detector, that will detect events for you, what more do you know about data? Those ineffective, discarded schemes - what rules have you used and what went wrong? Maybe it is salvageable? $\endgroup$ – Evil Jul 30 '16 at 22:42
  • $\begingroup$ The events eventually should be detected with a multi-class classifier, though the multiple classes are relatively similar and could be bucketed as one for now. The durations have a limited range (say, 30sec - 5min) but won't ever be 3sec or 20min long, for example. The rule-based system gets a lot of false-positives and -negatives, and therefore requires a lot of manual review. It also only makes use of one variable instead of multiple, and there's no clear way to improve this to a multi-class system. $\endgroup$ – FetchLaVache Jul 30 '16 at 23:16
  • 1
    $\begingroup$ Usually these kinds of machine learning approaches require some understanding of the application domain and what sorts of signals might indicate an event. Please give us some intuition from your application context: if you were going to try to find an event by eye, what kinds of patterns would you look for? What effects does an event might have on the observed values? $\endgroup$ – D.W. Jul 31 '16 at 3:28
3
$\begingroup$

Your first step is to characterize what effect you expect an event to have on your signals. Does it change the mean? Increase the mean? Change the variability? The more you can say about the type of effect it will have, the more specific a test you'll be able to build, and thus the more effective any analysis is likely to be.

Then, your second step is to apply appropriate techniques from the statistics literature on time series analysis. There are many techniques that look applicable here:

I recommend you start with some exploratory analysis. Based on the underlying physics/mechanics of how your system works, try to identify some ways that an event might affect the resulting signals. Also, do some exploratory data analysis: find some examples of known events, visualize the signals during those time periods, and hypothesize some feature values that seem to be affected during the signal (e.g., the mean got larger; the standard deviation got larger; the mean of the absolute value of the first derivative got larger; something like that). Finally, look for appropriate techniques in the statistical literature. If you can characterize the effect of an event well, you might be able to use change point detection techniques that will work well. If you can't characterize the effect of an event, you might need to fall back to some kind of machine learning, trained using a large training set... but you should still do each of the steps I listed, to help you identify what features might be useful to use in your machine learning model.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.