Why draw a line?
Why draw a line?
Imagine you have four students who studied for different numbers of hours. One studied for one hour and scored forty, another studied for two hours and scored fifty, another studied for three hours and scored sixty, and another studied for four hours and scored seventy. You can already see a pattern: more study tends to mean a higher score. But the real question is, how would you draw one line that captures that pattern? You could draw many possible lines through this cloud of points. One might pass above most of them, another below most of them, and another might run roughly through the middle. We want a rule that chooses the line that represents the relationship best. The key point is that we are not trying to connect every point perfectly. We are trying to capture the overall trend. Suppose our line predicts a score of forty-eight for two hours of study, sixty-one for three hours, and seventy-two for four hours. The predictions are close, but not identical to the observed scores. That difference is important. A machine learning model is useful precisely because it can make predictions for new inputs, not because it memorizes the old points. Now we can name the idea: linear regression. In the simplest case, it assumes the prediction changes at a constant rate as the input changes. We write the prediction as a line: y hat equals m times x plus b. The number m controls the slope, and b controls where the line crosses the vertical axis. Why not simply choose any reasonable slope and intercept? Because two different lines can both look reasonable, while one may make much larger prediction mistakes. So we need a way to judge the line using all the observed points. That brings us to the next question: how should we measure how wrong a line is? Pause here. Imagine two candidate lines. One is usually close but sometimes misses by a little more. The other is always moderately wrong. Which line should win? The answer depends on how we combine all of those individual mistakes into one score.
