On this page
If you can write the equation of a straight line from Class 11 maths, you already know most of linear regression. The new part is that the data, not you, chooses the slope and intercept. That is the core idea of machine learning.
What is linear regression, in Class 11 terms?
Google's Machine Learning Crash Course says linear regression is a statistical technique used to find the relationship between variables. It writes the model as y' = b + w1x1: your familiar y = mx + c, where the weight w is the slope and the bias b is the y-intercept, both calculated during training.
How do you fit a best-fit line by hand?
A made-up example: five classmates note their study hours for a unit test and their marks out of 100.
Hours (x): 1, 2, 3, 4, 5
Marks (y): 45, 52, 60, 63, 70
The rule is least squares: choose the line that makes the sum of squared vertical gaps between points and line as small as possible. The NIST/SEMATECH e-Handbook of Statistical Methods gives slope = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)² and intercept = ȳ − slope × x̄.
Find the means: x̄ = 3 hours and ȳ = 58 marks.
Write the deviations: x − x̄ is −2, −1, 0, 1, 2 and y − ȳ is −13, −6, 2, 5, 12.
Multiply them in pairs and add: 26 + 6 + 0 + 5 + 24 = 61.
Square the x deviations and add: 4 + 1 + 0 + 1 + 4 = 10.
Slope w = 61 ÷ 10 = 6.1 marks per hour.
Intercept b = 58 − 6.1 × 3 = 39.7.
Your line is marks = 39.7 + 6.1 × hours. The residuals (real minus predicted marks) are −0.8, 0.1, 2.0, −1.1 and −0.2; their squares add to 5.9, and no other straight line does better. For where the method came from, read our piece on Adrien-Marie Legendre and the method of least squares.
How do you check the line in a spreadsheet?
Type hours in A2 to A6 and marks in B2 to B6. In Google Sheets, =SLOPE(B2:B6, A2:A6) returns 6.1 and =INTERCEPT(B2:B6, A2:A6) returns 39.7; Google's help page describes SLOPE as the slope of the line from linear regression of a dataset. Matching numbers check your arithmetic.
Why is linear regression called machine learning?
Google's introduction defines machine learning as training a piece of software, called a model, to make useful predictions or generate content from data. A regression model, the same page says, predicts a numeric value, like your predicted marks.
The "learning" is the search for w and b. Google's course defines loss as a numerical metric that describes how wrong a model's predictions are, and says training aims to minimise it. Mean squared error, the average squared gap, is 5.9 ÷ 5 = 1.18 here. Least squares is training: it picks the weight and bias with the lowest loss.
Where does a best-fit line mislead?
The line only describes the points it saw.
Outside your data. At 12 hours it predicts 39.7 + 6.1 × 12 = 112.9 marks on a test out of 100. It crosses 100 at about 9.9 hours.
One point can swing it. Change the fifth mark from 70 to 50 and the slope falls from 6.1 to 2.1 marks per hour.
Same line, different data. Anscombe's quartet is four datasets with the same mean, variance, correlation and regression line that look quite different when plotted, from F. J. Anscombe's 1973 paper Graphs in Statistical Analysis.
A slope is not a cause. Students who study longer may also have better notes or more sleep. See Karl Pearson and the correlation coefficient, and Francis Galton on why extreme results drift back to average.
When can you trust a best-fit line?
Plot the points first and look for a rough straight-line pattern.
Predict only inside the range of x you measured.
Read the residuals; if they run positive, negative, positive, the pattern is probably curved.
Remove one point and refit; if the slope jumps, collect more data.
Name one other thing that changes with x before saying x causes y.
If minimising squared error still feels slippery, the Fermi Concept Library gives each concept in mathematics and computing its own lesson. Not sure where to start? Fermi's AI tutor can work out what you already know and build a plan for the session.
Try it tonight: log your own study hours and test marks for a few weeks, fit the line, then run the checklist.



