You fit a model that predicts exam scores from hours studied. It gives an answer for every student. But how good is it? One number is used most often to answer that: the coefficient of determination, written R squared. A value of 0.94 means the model explains 94 percent of the ups and downs in scores.
R squared sits at the heart of regression. It is the first number most reports show and the first one that gets misused. People treat a high value as proof that the model is right, or a low value as proof that it is useless. Neither is true and this tutorial shows why.
You will learn what R squared means, its formula in plain steps, a fully worked example, how it links to correlation, what a good value looks like, adjusted R squared, the cases where R squared can be negative, and how to calculate it in Python.
The coefficient of determination is a statistic that tells you what share of the variation in the outcome is explained by the model. It is written R squared (R2). It is also called a goodness of fit measure.
An R squared of 0.50 means that about half of the observed variation in the outcome is explained by the model. The rest is left unexplained, because of other factors or random noise.

In a simple linear model, R squared equals the square of the correlation coefficient r. If r is 0.97, then R squared is 0.94. A value of 1 is a perfect fit. A value of 0 means that the model does no better than predicting the average every time.
Important: R squared shows association, not cause. The live page says it shows how much variability in one factor another can cause. A model with a high R squared does not show that one thing causes the other.

The fraction SS residual divided by SS total is the share left unexplained. Subtract it from 1 and you get the share explained.
For simple linear regression, there is a shortcut: R squared = r times r.

Eight students study 1 to 8 hours and score 52, 55, 61, 60, 68, 72, 70 and 79. The data are made up for teaching.
Meaning: hours studied explain about 94 percent of the variation in scores. The other 6 percent comes from things the model does not know, such as sleep, past knowledge or luck.
There is no single answer. It depends on the field and on the goal.
| Situation | What to expect |
|---|---|
| Physics or lab measurement | Very high, often above 0.95 |
| Business forecasting | Moderate values can still be useful |
| Human behaviour, social data | Low values, such as 0.2 or 0.3, are common |
A high R squared can still go with a bad model. It can come from overfitting, a model that matches the noise in the training data. A low R squared can go with a useful model, when the effect is real but the data are noisy. Always look at residual plots, and test on new data.
On the training data, R squared never goes down when you add a predictor, even a useless one. So it can reward a model for being bigger, not better. Adjusted R squared corrects for this with a penalty for the number of predictors. Use it when you compare models with different numbers of predictors.
Adjusted R squared = 1 minus (1 minus R squared) times (n minus 1) divided by (n minus k minus 1), where n is the number of observations and k is the number of predictors. In the example, n is 8 and k is 1, which gives 0.9322.
The live page says that R squared lies between 0 and 1. For a least squares line tested on the data it was fitted to, that is true. But when a model is scored on new data, or when it is not fitted by least squares, SS residual can be larger than SS total, and R squared becomes negative. It means the model is worse than simply predicting the average. In the code below, a model that always predicts 40 for these scores gets R squared of minus 8.25.
I ran the code below, and the output is real.
| Mistake | Fix |
|---|---|
| Treating a high R squared as proof of cause | R squared shows association only |
| Calling R squared accuracy | It measures fit to the data |
| Saying it must be between 0 and 1 | It can be negative on new data or for a poor model |
| Adding predictors only to raise R squared | Use adjusted R squared, and test on new data |
| Judging a model by R squared alone | Check residual plots and errors such as RMSE |
| Comparing R squared across different outcomes | Compare only models for the same outcome |
| Using it for a curved relationship with a straight line | Plot the data first |
Answers: 1) 1 minus 20 divided by 80 = 0.75. 2) 0.8 times 0.8 = 0.64. 3) 38 percent. 4) Yes, when a model fits worse than the mean, for example on new data. These are my own answers, so please recheck them before publishing.
R squared is a useful first look at a model, not a verdict. Read it as the share of variation explained, pair it with residual checks and new data, and never use it alone to claim that one thing causes another.