Could you share the part of the code to obtain: Figure 9. The CWT applied on two signals belonging to the UCI HAR dataset ?

I used plt.matshow, but the resolution is different, and i do not know which signal you used for comparison. Thank you very much. ]]>

If it is something where the location in the time-series is relevant like āremaining useful life time predictionā then you should also keep track of which part of the signal you get each block and maybe use it as an additional feature ]]>

I think you are doing an āout of timeā split to split each signal into a part train and part test, right?

Because you could also split it āout of sampleā where each signal is either in train or in test.

In any case you should first split and then transform to prevent leakage.

If you have a signals of 100 sec, you could split it into 50s of train and 50s of test. If you have unequal lengths for train/ test for example 80s for train and 20s for test you could also apply a windowing function to split the train part into blocks of 20s.

If you want to apply windowing, you have to make sure there are no blocks which are both in the train and test set.

def get_fft_values(y_values, T, N, f_s):

f_values = np.linspace(0.0, 1.0/(2.0*T), N//2)

fft_values_ = fft(y_values)

fft_values = 2.0/N * np.abs(fft_values_[0:N//2])

return f_values, fft_values

t_n=1

N = 100000

T = t_n / N

f_s = 1/T

xa = np.linspace(0, t_n, num=N)

xb = np.linspace(0, t_n/4, num=N//4)

frequencies = [4, 30, 60, 90]

y1a, y1b = np.sin(2*np.pi*frequencies[0]*xa), np.sin(2*np.pi*frequencies[0]*xb)

y2a, y2b = np.sin(2*np.pi*frequencies[1]*xa), np.sin(2*np.pi*frequencies[1]*xb)

y3a, y3b = np.sin(2*np.pi*frequencies[2]*xa), np.sin(2*np.pi*frequencies[2]*xb)

y4a, y4b = np.sin(2*np.pi*frequencies[3]*xa), np.sin(2*np.pi*frequencies[3]*xb)

composite_signal1 = y1a + y2a + y3a + y4a

composite_signal2 = np.concatenate([y1b, y2b, y3b, y4b])

f_values1, fft_values1 = get_fft_values(composite_signal1, T, N, f_s)

f_values2, fft_values2 = get_fft_values(composite_signal2, T, N, f_s)

fig, axarr = plt.subplots(nrows=2, ncols=2, figsize=(12,8))

axarr[0,0].plot(xa, composite_signal1)

axarr[1,0].plot(xa, composite_signal2)

axarr[0,1].plot(f_values1, fft_values1)

axarr[1,1].plot(f_values2, fft_values2)

(…)

plt.tight_layout()

plt.show()

Thank a lot. You are right actually, looks like the arrows are pointing from the wrong coefficients.

I’ll update it asap. ]]>

Thank you for the great content, it helped me a lot.

I have a question. In feature extraction steps you are using the output from the “pywt.wavedec” function. The “pywavelet” documentation states that the output is [cA_n, cD_n, cD_n-1, …, cD2, cD1] (n is the level), however in your figure it looks like the features are created from only the approximation coefficients. Don’t the features come from the last approximation coefficients and all the detail coefficients? ]]>