Interpretation of $R^2$ (coefficient of determination) I found two different and contradictory definitions / interpretations of $R2$. They cannot be true at the same time and I don't know how to tell which one is true.

*

*$R^2$ is just a square of Pearson's correlation. Hence its value ranges between $[0, 1]$

*$R^2$ is equal to
$$1 - \dfrac{SSE}{SST}$$
and can be negative if the model is worse than random. For example - in Python's sklearn function r2_score can return a negative number.
Are those two different $R^2$s? Why are there two contradictory definitions? Can anyone explain it comprehensively?

In a simple setting where you fit a linear model, using ordinary least squares, and include an intercept, multiple definitions of $R^2$ give equal values.

*

*In simple linear regression (just one slope and the intercept), Pearson correlation between the $x$ and $y$ values


*Squared Pearson correlation between predicted and true $y$


*Proportion of variance explained by the regression


*Your second definition: a comparison of the square loss of your model to the square loss of a naïve model that always predicts the overall (pooled, marginal, unconditional) mean of $y$
(There are others, as discussed in this link given in a comment by whuber.)
In simple settings, these give the same answer, so people use them interchangeably as the definition of $R^2$. However, in more complex settings, there are differences. I get into some of those differences here and explain my support for the last of the four.
