This is an excellent blog! Thank you for sharing valuable insights on signal processing. Appreciate your efforts.

I’m working on a similar problem of human activity recognition using smartphone accelerometer data. The data contains tri-axial signals only from accelerometer around x, y, z axes. The training data for signals and labels has been separately provided with different shape and sampling frequencies for both. The signals data is sampled at 10 Hz (0.1 seconds per sample) and contains total 3744 samples and 3 components. Whereas, labels data is sampled at 1 Hz (1 second per sample) and contains 375 samples. In other words, labels are provided for every 10th observation in signals data. Signals and labels can be joined using timestamp.

My approach: The above suggests that each labeled signal has 10 signal samples. Assuming this, I transformed the signals dataframe of shape (3744, 3) into a numpy array of shape (375, 10, 3). I extracted 90 features using frequency transformations with signal parameters T = 0.1 sec, N = 10, f_s = 1 Hz. I also extracted 72 wavelet features from the signals. I combined both frequecy and wavelet domain features to train a classifier that classifies signals into four activities – standing (7% samples), walking (57%), stairs down (12%), stairs up (23%).

Results: The classifier fits training data with 100% accuracy. However, the test score is not satisfactory (30-40%) which signifies overfitting. Also classifier does not classify standing activity at all and predictions are remaining three classes.

I have ran multiple iterations, but not able to reach reasonable test accuracy. It will be great if you could share any inputs to – 1) review my approach, 2) validate the signal parameters used for frequency transformation, and 3) anything I’m missing or any alternative approach to improve the test score.

Regret long post. Thanks in advance for your response.

]]>I really thank you for this explanation. I have some questions and I hope you get free time to give me your miracle guidance.

I’m really sad that whenever we are talking about signal and signal processing all get focus on multivariate ….

I am working with time series forecasting and I have some problems with padding and signal extension when using wavelet.

as you know distortion happens in two edges of the finite signal(time series here) then we should use a signal extension method to extend signal then our main signal will be unaffected.

in time series maybe the historical data available to extend but it is the main problem for the right edge because we do not know the future value(this problem is much more important for online models) so we use prediction engines to get artifact future samples to extend the signal.

some formula to calculate the number of samples we need is (FilterLenght-1)*(2**(DecLevel-1)

could you please tell me or give an example code(more realistic) how can we use artificial data to extend the signal appropriately for the different levels to reduce the distortions

Sincerely I am waiting for your replay

Best Regards ]]>

It convinced me to investigate further onto wavelet transformation topic. ]]>

As I am a beginner in machine learning I would like some material for studying forecasting and python .

Thanks for all.

Best regards,

Adilson ]]>

Finally after struggling for couple of days, I found a right technical blog. Thanks for sharing.

I am working with accelerometer data (I have ML and DL understanding) and completely new to signal processing domain i.e. FFT and Wavelet etc. I am trying “Count a device movement using Accelerometer data”. It would be great if you can help me with your expertise. Basically, I am trying to solve this problem (kindly look at stackoverflow question): https://stackoverflow.com/questions/61204254/fft-calculation-for-accelerometer-data

Please share your views and suggestions!

]]>#plot

fs = 50

scales = np.arange(1,128) #len(of the signal)

t = np.arange(len(uci_har_signals_train[0, :, 3]))/fs

[coefficients, frequencies] = pywt.cwt(uci_har_signals_train[0, :, 3],scales, ‘morl’, 1)

#levels = frequencies[-1:0:-1]

levels = 20

#contourlevels = (levels)

fig,ax = plt.subplots(figsize = (10,8))

im = ax.contourf(t, frequencies,np.log10(np.abs(coefficients)**2),levels,cmap=plt.cm.seismic)

#yticks = 2**np.arange(np.ceil(frequencies.min()), np.ceil((frequencies.max())))

#ax.set_yticks([])

#ax.set_yticklabels([])

ax.invert_yaxis()

ylim = ax.get_ylim()

#ax.set_ylim(ylim[0], -1)

But the result is not similar to the one you obtain.

Thank you for the response

]]>I was wondering if you can share the code to obtain Figure 9, which is the scalogram from CWT on the 9 signals of the HAR dataset. I’ve tried to obtain them, but I have some troubles to get the same results, it is pretty similar, but tends to be messy.

Thanks in advance

]]>grad1 = (2.0/m)*sum([(func1(X[iter], theta, False) – Y[iter])*X[iter][1]**4 for iter in range(m)]) ]]>

by the way, I am curious way you add dt in function pywt.cwt()? as,

[coefficients, frequencies] = pywt.cwt(signal, scales, waveletname, dt) ]]>