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.
- Normalize X using the formula: x = (X - X_mean) / (X_max - X_min)
- Normalize y using the formula: y = (Y - Y_mean) / (Y_max - Y_min)
- Train your algorithm using the normalized input features (X) and the normalized output variable (y).
For prediction on validation/test data
- 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.
- Predict the values of the normalized output variable (y_pred) using your trained algorithm.
- 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.