The equation of a first order linear Regression is simply
The Linear Regression is the line that minimizes the cost function. By that, we have that LR is the line that best fit the points we got on our experiment. We can see an example in the Figure 1, the line that best fits the Budget vs Box Office.
As a method of prediction we need some metrics to evaluate if our model is good or not. For tha we calculate the residuals, as follows
Now we can utilize some metrics to evaluate, using residuals as follows. For instance, we can utilize the metric os Mean Absolute Error(MAE)
or utilizes the metric of Mean Squared Error(MSE)
The mean absolute error (MAE) is the simplest regression error metric to understand. We’ll calculate the residual for every data point, taking only the absolute value of each so that negative and positive residuals do not cancel out. We then take the average of all these residuals. Effectively, MAE describes the typical magnitude of the residuals. Mathematically we can see as the mean of the
The Mean Absolute Error (MAE) is a metric that provides an intuitive measure of the difference between the actual data and the predictions made by a model. It quantifies the absolute difference without considering the direction of the errors. By taking the absolute value of the residuals, the MAE does not indicate whether the model underperforms or overperforms (i.e., whether it consistently underestimates or overestimates the actual data). Each residual contributes proportionally to the total error, so larger errors have a linear impact on the overall error. A small MAE suggests that the model is highly accurate in its predictions, while a large MAE indicates potential issues in certain areas. It's important to note that achieving a MAE of 0, meaning a perfect prediction, is extremely rare.
Although the MAE is easy to interpret, using the absolute value of the residuals may not always be the preferred approach. Depending on how you want your model to handle outliers or extreme values in the data, you may want to give more emphasis to these outliers or downplay their impact. The presence of outliers can significantly affect the choice of an appropriate error metric.
The mean square error (MSE) is just like the MAE, but squares the difference before summing them all instead of using the absolute value. We can see this difference in the equation below. Mathematically we can see as the mean of the
When we square the difference between the data and the model's predictions, the result is the Mean Squared Error (MSE), which tends to be larger than the Mean Absolute Error (MAE). Due to this squaring operation, direct comparison between the MSE and MAE is not meaningful. Instead, we compare the error metrics of our model with those of competing models.
The impact of the squared term in the MSE equation becomes more pronounced when dealing with outliers in the data. While each residual in the MAE contributes proportionally to the total error, the error in the MSE grows quadratically. Consequently, outliers have a much greater influence on the total error in the MSE compared to the MAE. Moreover, the model is more heavily penalized for making predictions that significantly deviate from the corresponding actual values. In other words, large differences between actual and predicted values are punished more severely in the MSE than in the MAE.