Let's try to understand both of these metrics.
- Mean Squared Error (MSE): The MSE measures the average squared difference between the actual values and the predicted values. It is calculated by taking the mean of the squared differences between each actual value and its corresponding predicted value. Mathematically, the MSE is given by:
where: (n) is the number of data points. (y_i) represents the actual value. (\hat{y}_i) represents the predicted value.
- Root Mean Squared Error (RMSE): The RMSE is the square root of the MSE. It provides a measure of the average absolute error between the actual and predicted values. Mathematically, the RMSE is given by:
Now, let’s calculate these metrics manually using an example dataset:
Suppose we have the following actual and predicted values:
- Actual values: [10, 15, 20, 25, 30]
- Predicted values: [12, 18, 22, 24, 28]
- Calculate MSE: MSE = (1/5) * [(10-12)^2 + (15-18)^2 + (20-22)^2 + (25-24)^2 + (30-28)^2]) = 4.40
- Calculate RMSE: RMSE = sqrt(4.40) = 2.10
So, the MSE is 4.40, and the RMSE is 2.10 for this example dataset.
Remember that both MSE and RMSE provide insights into how well a regression model performs, with lower values indicating better performance. RMSE is often preferred because it is in the same unit as the original data, making it more interpretable.
Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.