Linear Regression: Drawing the Best Line Through Messy Data
If you've ever tried to guess what a flat should rent for, you've already done a rough version of linear regression in your head. Bigger flat, higher rent. Closer to the station, higher rent again. You weigh those things, add them up, and land on a number.
Linear regression is just that habit, made precise. It's usually the first model people learn, and honestly, it's one I still reach for before anything fancier.
The idea
You have inputs (size, age, distance to the metro) and one number you want to predict (rent). Linear regression says the answer is a weighted sum of the inputs, plus a starting value:
y = w1*x1 + w2*x2 + ... + b
Each weight tells you how much the prediction moves when that input goes up by one unit, with everything else held still. The b is the baseline, what you'd predict if every input were zero.
With a single input, this is the line from school: y = mx + c. With many inputs, it's a flat surface in higher dimensions.…