Before you can trust the formula
R2=1−SStotSSres
you need to know what every single symbol in it means as a picture, not as a squiggle. Below we unpack them one at a time, each building on the last. Nothing is used before it is drawn.
Picture it: scatter a handful of dots on a graph. Each dot's height is one yi. That's all a dataset is — a bunch of heights.
Why the topic needs it: these are the truths the model is trying to reproduce. Everything else — the average, the misses, the score — is built by comparing things to these dots.
Picture it: draw one flat horizontal line through the middle of your dots. That line is yˉ. It's the "I know nothing, so I'll just guess the average for everyone" line.
Picture it: if the model is a straight line (as in Linear Regression), then y^i is the height of that sloped line directly above data point i.
Why the topic needs it: the whole point of R2 is to compare the guesses y^i against the truths yi. Both symbols must be crystal clear before we can talk about "error."
Why we square it — squaring is the tool, and here's why that tool: if we just added raw residuals, the positive ones (+10) and negative ones (−10) would cancel and hide the errors, wrongly reporting "no error." Squaring turns every gap positive (a negative times a negative is positive) and punishes big misses more than small ones (102=100 vs 22=4). This is exactly the idea behind Mean Squared Error.
Now we combine everything: the counter, the sum, the mean, the guesses, and the squaring.
Now the master formula reads in plain English:
R2=1−SStotSSres=1−baseline’s errormodel’s leftover error
If the model kills most of the error, the fraction is near 0, so R2 is near 1. If the model does no better than the average, SSres=SStot, the fraction is 1, and R2=0.