Applying an ML Algorithm is Not Enough!

Previously on…

In the previous post, we discussed the Mean Absolute Deviation and how it can be a useful tool for evaluating the performance of a machine learning model when the data is affected by extreme values.

Another very interesting measure is the R-squared (\(R^2\)), which, unlike the Mean Squared Error, is a proportion and always takes values between zero and one.

\[ R^2= 1-\frac{\sum_{i=1}^n(y_i- \hat{f}(x_i))^2}{\sum_{i=1}^n (y_i-\bar{y})^2} \]

where \(y_i\) represents the \(i\)-th observed value of the dependent variable, \(\hat{f}(x_i)\) is its prediction that depends on a set of covariates \(x_i\), \(\bar{y}\) is the sample average of the observed values, and \(n\) is the sample size.

The \(R^2\) measures the proportion of total variability in the data that the machine learning model (e.g., Linear model) is able to capture.

When should it be used? - This metric is commonly used to measure the goodness of fit of the data, which means how well the algorithm can explain the data.

How do we interpret? - An \(R^2\) value close to 1 indicates that the used model explains the data well, while a value close to zero indicates that the model is not adequate in explaining the phenomenon.

Why is it widely used? - There exists a well-known relationship between \(R^2\) and linear correlation. In fact, it can be shown that the \(R^2\) is the square of the correlation, in linear regression contexts. - In linear regression contexts, it is the most commonly used metric to evaluate the goodness of fit, which measures how well the linear model fits the data.

Drawbacks - High \(R^2\) values do not always correspond to good models. In such cases, the analyst needs to exercise judgment and, if necessary, plot the data to have a clear representation of the problem.

Anscombe’s quartet is a famous statistical example that consists of four datasets with nearly identical descriptive statistics but vastly different visual representations, each having an equal R^2 (0.67). The quartet was created by the statistician Francis Anscombe in 1973.
Anscombe’s quartet is a famous statistical example that consists of four datasets with nearly identical descriptive statistics but vastly different visual representations, each having an equal \(R^2\) (0.67). The quartet was created by the statistician Francis Anscombe in 1973.