# Using Signal to Noise Ratio (SNR) formula for machine learning metric evaluation

As the SNR function is not commutative (meaning different argument positions will lead to different output results), it makes me confused to use it as metric evaluation.

I have this 3 signal; those are X_test, y_test, and y_pred. Those are common naming conventions for supervised learning models. So what are they for common people?

• X_test is basically input of an ML model, which is noisy signal.
• y_test is basically a denoised signal, which is the ground truth of clean signal.
• y_pred is basically a denoised signal, which is a predicted clean signal by model.

The question is, how do I know how much the signal has been denoised? There are some combinations, but I don't know which one. Is it:

1. SNR(X, y)
2. SNR(y, X)
3. SNR(y_test, y_pred)
4. SNR(y_pred, y_test)

Sorry, I didn't define the SNR function due to being unsure of what SNR formula I should use.

If you are wondering what SNR am I being used (might be wrong), here it is:

def SNR(a, b):

# At this point I don't know what is a or b? And which one is denoised and noised.

# Calculate the power of the true signal
true_signal_power = np.sum(np.square(a), axis=1)

# Calculate the power of the noise (difference between true and predicted signals)
noise_power = np.sum(np.square(a - b), axis=1)

# Calculate SNR in decibels
snr = 10 * np.log10(true_signal_power / noise_power)

return snr


The remaining is simply the difference between the noise signal and the clean signal. You can define 3 different SNRs here

The SNR of your original signal is

$$SNR_{original} = 10\log_{10}\frac{\sum y_{test}^2}{\sum (x-y_{test})^2}$$

After the denoising the SNR is

$$SNR_{denoised} = 10\log_{10}\frac{\sum y_{test}^2}{\sum (y_{pred}-y_{test})^2}$$

The SNR improvement is then simply the difference of the two

$$SNR_{improvement} = SNR_{denoised} - SNR_{original} = 10\log_{10} \frac{\sum (x-y_{test})^2}{\sum (y_{pred}-y_{test})^2}$$

• Could you explain the difference between SNR improved and SNR denoised? My brain interpreted both as same, no difference. Commented Jun 15 at 16:34
• I'm skeptical about $$SNR_{denoised}$$, it accepts y_pred and y_test. I mean, how you imply y_pred is denoised signal of y_test? I mean both of them supposed to be clean signal, there is nothing compare, CMIIW. Commented Jun 16 at 2:40