I have electric signals represented as 2(internal)d data. Each data point is in the form (<timestamp>, <power_value>). I want to be able to differentiate 4 different states that a window of the signal can belong to.

To give you a better understanding here is an example of how the signals look like

raw power data

Here we can see all 4 different states represented.

  • Off - it's when the signal is completely stationary and its amplitude is bellow the standard deviation in this case. You can see a small part a little bit before the end of the plot

  • Idling - when the signal is stationary but its amplitude is close to the mean level. Like in the beginning of the plot.

  • Stand-by - Areas where the signal has some noticeable variation like right after the second spike.

  • On - Areas with a lot of variation and high frequency

I want to be able to determine in which of those states a specified length window (the length is something that must be discussed too) belongs to.

What I have done so far is quite simple and a bit amateurish. I trained a Random Forest using just two features, the mean of a window and the variance of a window. In order to run the classification I apply the classification on a sliding window and each time I label the first data point.

I started off with that because at first the classification had to be able to differentiate just 3 states (off, idling, on) which even with those simple statistical features is very easy. I could even as well right a simple if-then-else instead of training decision trees and the results would be as accurate because those three states have very distinct values for those features. But with adding a fourth state the classifier misfires a lot. And that's normal. It might not be very well depicted in that picture above but Stand-By and On, in particular areas, have a bit common variance and averaged values.

I am not interested in going for a pattern matching approach, although that could solve all those problems robustly but that would also mean that I would have to create sets of reference patterns which gives rise to many different implications.

What I am looking for is a set a features that will enable me to efficiently differentiate those states. First do you think that is even possible?

My understanding tells me that maybe a set of frequency domain features could improve the accuracy. I have only used such features (MFCC) once though, for audio classification, but that doesn't apply to this case.

If you think that this is possible, can you recommend a set of features that it would make sense to try out, or point me to a study that you think is well suited for this case?


After MikeP's suggestion I created a spectogram using Octave's specgram with the default arguments

Here is an instance of the signal enter image description here

and here is the spectogram enter image description here


After some days working on the problem I managed to make some progress. I experimented with different sets of features and added a few new ones.

What I did was to extend my statistical features by adding the skewness and the kurtosis. I also moved towards a more pattern matching approach by adding dtw distances from reference patters (one of each state). That last step improved the results on the sliding window classification quite a bit.

My problem still lies on the sliding technique I use for the classification, since every time the window falls into intermediate (also unlabeled) cases the classifier has a hard time concluding on what is that it is seeing.

What I am trying to do now is to use SVM instead of RandomForests with a polynomial kernel (degree 4). I am using the scikit-learn implementation. The problem is that the classifier is always categorizing the data as state_3. I think I am imposing some kind of bias, but I don't know why and how. Do you have any ideas what might be going wrong?

To get an idea how the labeling looks, here are some labeled instances of the signal

enter image description here


Instead of polynomial kernel, I used a linear kernel for the SVM, and the classifier worked correctly. Actually I got the best results so far. I might have to work extra on making the whole classification pipeline more efficient because svm's and the extra feature extraction is making everything very slow

  • 2
    $\begingroup$ Can you create a spectrogram of the data? If it's in matlab, that should be very easy. By visualizing the amplitude over frequency, the features might become much clearer. $\endgroup$
    – MikeP
    Commented Mar 4, 2016 at 15:32
  • $\begingroup$ I updated the question accordingly $\endgroup$ Commented Mar 4, 2016 at 18:36
  • 1
    $\begingroup$ Thanks!!! You might actually find fewer frequency bins (smaller fft size) better for classification. It 'looks' like the yellow vs blue is a little more intense midway up the frequency range during on, versus standby - and way more dense than off. $\endgroup$
    – MikeP
    Commented Mar 4, 2016 at 19:11
  • $\begingroup$ A numerical approach such as Fast Fourier Transforms (FFT) may help. FFTs are widely used to decompose signals like this. There are a variety of features that would be included such as frequency, amplitude, density, etc. Here's a Wiki link: en.wikipedia.org/wiki/Fast_Fourier_transform $\endgroup$
    – user78229
    Commented Mar 9, 2016 at 14:24
  • $\begingroup$ I tried to use the spectral centroid but it didn't increase the accuracy. But again maybe it did. As you can see from the last image basically all four states can be predicted just by the mean and var. With using the sliding window for applying on-line classification I am looking for features that will make the classifier be less prune to rapid changes. Adding features that increase that accuracy made the on-line classifer misfire a lot, probably due to over-fitting. But again, I didn't try out freq amp and density so I will do, thanks $\endgroup$ Commented Mar 9, 2016 at 14:31

1 Answer 1


From my experience, often the mass calculation of different features with subsequent inspection of their significance can lead to interesting insights. You could use the python package tsfresh to automatically extract a huge of number of features and filter them for their importance.

You described that you calculated both frequency domain, skewness and kurtosis features. Those are also contained in tsfresh. But there is a huge number of other time series characteristics that can be also used as potential features for audio classification. There are simple features such as the mean, time series related features such as the coefficients of an AR model or highly sophisticated features such as the test statistic of the augmented dickey fuller hypothesis test.

So regarding your question: You can find inspiration about other features in the documentation about the calculated features of tsfresh here.

Disclaimer: I am one of the authors of tsfresh.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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