flâneur — a map of the web's best reading

Explaining negative R-squared. Why and when does R-squared, the… | by Tan Nian Wei | Towards Data Science

towardsdatascience.com · 1,338 words · saved by 1 readers

Colour me surprised when the `r2_score` implementation in sklearn returned negative scores. What gives? This article is adapted from my original blogpost here R² is defined upon the basis that the total sum of squares of a fitted model is equal to the explained sum of squares plus the residual sum of squares, or: where: R² itself is defined as follows: Given these definitions, note that negative R² is only possible when the residual sum of squares (SS_res) exceeds the total sum of squares (SS_tot). As this is not mathematically possible, it can only mean that the explained sum of squares and residual sum of squares no longer add up to equal the total sum of squares. In other words, the equality in Equation 1 does not appear [1] to be true. How can this be? Following the above definitions, SS_tot can be calculated using just the data itself, while SS_res depends both on model predictions and the data. While we can use any arbitrary model to generate the predictions for scoring, we need

Explaining negative R-squared | Towards Data Science Skip to content Data Science Explaining negative R-squared Why and when does R-squared, the coefficient of determination, go below zero Tan Nian Wei Jun 9, 2022 5 min read Share When I first started out doing machine learning, I learnt that: R² is the coefficient of determination, a measure of how well is the data explained by the fitted model, R² is the square of the coefficient of correlation, R, R is a quantity that ranges from 0 to 1 Therefore, R² should also range from 0 to 1. Colour me surprised when the r2_score implementation in skle

Explore this link on the map →

related reading