Azzera filtri
Azzera filtri

Machine Learning-Mean Normalization

11 visualizzazioni (ultimi 30 giorni)
Ioannis Tsikriteas
Ioannis Tsikriteas il 4 Ago 2018
Modificato: Shantanu Dixit il 19 Giu 2023
Hi, I have the folowing problem!
In order to train my algorithm i aply Mean Normalization on my training data.
Then, on the trained algorithm i try to predict using my Validation data with a very good performance (low rmse).
The problem is when i try to unnormalize my data, which means to have the predicted data without the mean normalization...at this part my result is gone!!!!
To be more specific i apply mean normalization on my training data (x=(TrainData-Mean)./(Max-Min)) and i train the algorithm. Then i apply Mean Normalization on my Validation Data (y=(ValData-mean)./(max-min)) and i apply the prediction on y.
The problem is that i don't know which Mean/mean, and Max-Min/max-min should i add and multiply on my predicted data (ypred) in order to have a correct prediction according my original data!
I tried both but the result was totally wrong. What is my mistake in the process?

Risposte (1)

Shantanu Dixit
Shantanu Dixit il 16 Giu 2023
Modificato: Shantanu Dixit il 19 Giu 2023
Hi Ioannis,
Mean normalization or feature scaling is typically applied to the input features (X) and not the output variable (y). It is not necessary to normalize the output variable (y) in most cases, especially if you are using regression algorithms.
If you have applied mean normalization only to your input features (X), refrain from applying any mean normalization to your output variable (y). Instead, you can directly use the predicted values obtained from your trained algorithm without any additional scaling or denormalization steps.
Following are the steps for feature scaling:
1. Apply mean normalization or feature scaling to your input features (X).
2. Train your algorithm using the normalized input features (X) and the original output variable (y).
3. Predict the values of the output variable (y_pred) in your dev/test set using your trained algorithm.
Use the predicted values (y_pred) as they are, without any additional scaling or denormalization steps.
However if you still want to apply normalization on the output variable (y), following steps are required to ensure correct prediction:
Apply mean normalization or feature scaling to both the input features (X) and the output variable (y) separately.
  1. Normalize X using the formula: x = (X - X_mean) / (X_max - X_min)
  2. Normalize y using the formula: y = (Y - Y_mean) / (Y_max - Y_min)
  3. Train your algorithm using the normalized input features (X) and the normalized output variable (y).
For prediction on validation/test data
  1. Normalize the validation input features (X_val) using the formula: x = (X_val - X_mean) / (X_max - X_min) . Here, X_mean, X_max, and X_min are the mean, maximum, and minimum values calculated from the training data.
  2. Predict the values of the normalized output variable (y_pred) using your trained algorithm.
  3. In order to obtain the predicted values in the original scale, you will need to denormalize y_pred.
Denormalize y_pred using the formula: y_pred_denormalized = (y_pred * (Y_max - Y_min)) + Y_mean.
Again, Y_mean, Y_max, and Y_min are the mean, maximum, and minimum values calculated from the training data.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by