For the CNN + CWT example, I am not getting the same accuracy as you:

—

5000/5000 [==============================] – 32s 6ms/step – loss: 0.4976 – acc: 0.8670 – val_loss: 0.6622 – val_acc: 0.7460

Epoch 2/10

5000/5000 [==============================] – 37s 7ms/step – loss: 0.1874 – acc: 0.9300 – val_loss: 0.5222 – val_acc: 0.8140

Epoch 3/10

5000/5000 [==============================] – 45s 9ms/step – loss: 0.1634 – acc: 0.9378 – val_loss: 0.4913 – val_acc: 0.8460

Epoch 4/10

5000/5000 [==============================] – 47s 9ms/step – loss: 0.1698 – acc: 0.9428 – val_loss: 0.6755 – val_acc: 0.7320

Epoch 5/10

5000/5000 [==============================] – 51s 10ms/step – loss: 0.1681 – acc: 0.9388 – val_loss: 0.6140 – val_acc: 0.7860

Epoch 6/10

5000/5000 [==============================] – 52s 10ms/step – loss: 0.1501 – acc: 0.9450 – val_loss: 0.6650 – val_acc: 0.7020

Epoch 7/10

5000/5000 [==============================] – 51s 10ms/step – loss: 0.1266 – acc: 0.9530 – val_loss: 0.3773 – val_acc: 0.8420

Epoch 8/10

5000/5000 [==============================] – 53s 11ms/step – loss: 0.0983 – acc: 0.9630 – val_loss: 0.6188 – val_acc: 0.7080

Epoch 9/10

5000/5000 [==============================] – 51s 10ms/step – loss: 0.2276 – acc: 0.9372 – val_loss: 0.4089 – val_acc: 0.8020

Epoch 10/10

5000/5000 [==============================] – 52s 10ms/step – loss: 0.1920 – acc: 0.9492 – val_loss: 0.4823 – val_acc: 0.7540

Train loss: 0.14876973194935286, Train accuracy: 0.9456

Test loss: 0.48233831304311753, Test accuracy: 0.7540000004768371

—

The test accuracy is only 75% compared to your 94%. Do you have any ideas on why this could be the case?

Any idea why?

Thanks anyway. ]]>

Great stuff…. thanks for your time in putting this together.

]]>Thanks for the comment!

I was referring to the later period 1960 and upwards, where you can also see higher values in the longer periods (32 years).

`pywt.cwt()`

actually returns two items: coefficients and frequencies.

frequencies is indeed a one dimensional array, but coefficients is an two dimensional array!

print(coefficients.shape) –> (127, 503)

print(frequencies.shape) –> (127,)

If have never tried it myself, but you can try to generate features out of each row of the ‘coefficients’ array (or out of every n rows).

Good luck!

]]>Thank you so much for this post, it’s super enlightening! I have a few minor questions though.

For the CWT scaleogram in Figure 8, how did you observe the “shift from shorter to longer periods as time progresses”? It seems the exact opposite to me, for as the time progresses, the peaks of positive periods (red parts) shift upward to the region where periods are shorter?

Also, I’m currently dealing with some seismic signals, which are better processed by continous wavelets like Morlet or Ricker Wavelet, but I’m using LGBM. So I wonder if there’s a way to extract features from CWT like you did in section 2.5 from each sub-band on DWT? I see that pywt.cwt() returns a 1 dimension coefficient array just like DWT, but it seems I need to manually enter each scale? I’m kinda confused…

Once again really appreciate your time and insights!

]]>This really depends on the input signal. For example, if it has a high sampling rate there is a large chance there will outliers in the signal and standard scaling of min/max scaling do not perform optimally. Then I scale with percentiles instead of the min and max. Like this:

def normalize_signal(signal):

p99 = np.nanpercentile(signal, 99.9)

p01 = np.nanpercentile(signal, 0.1)

height = p99-p01

normalized_signal = ((signal – p01) / (height/2)) – 1

return [p01, p99, normalized_signal]

I guess this corresponds with the RobustScaler. You can also have a look here for a comparison of the different scalers.

https://scikit-learn.org/stable/auto_examples/preprocessing/plot_all_scaling.html

how to do that? ]]>

I think that the result of the CWT pre-processing of the signal will be positive and negative and Max will be different. By the way,

How did you Nomalize the value before putting it in deep running?