Linear RegressionUnderstanding What Our Line Means
A big strength of linear regression is that its numbers mean something you can say in plain words. Riya's line is .
- The slope, 6: every extra degree of temperature brings about
more kulfis. - The intercept, −100: at 0 °C the line predicts
kulfis.
Minus 100 kulfis? Riya cannot un-sell a kulfi. What went wrong?
Riya's data only covers 24 °C to 40 °C. Using a model far outside the range of its data is called extrapolation, and it is risky: the line has no idea what happens on a cold day. Inside the range, the intercept is just the number that puts the line at the right height.
More Than One Feature
Riya notices that on school holidays the street is empty. She adds a second feature, , which is 1 on a holiday and 0 on a school day — a yes/no feature. Her new model is
Read each coefficient as "the change in when this feature goes up by 1 and every other feature stays the same". For a yes/no feature that is simply the difference between the two groups: on a holiday Riya sells
Does a Straight Line Make Sense?
Linear regression always draws a straight line — even when the data is not straight. For which of these datasets is a straight line a bad idea?
A U-shape needs a curve, so a straight line would be too low in the middle and too high at both ends. Two more checks before you trust a line: the errors should look random (no pattern in the red segments), and the data should come from the same kind of situation as the one you predict for.
Speed Round: Read the Line
Get five right to move on.