The absolute trick adjusts a regression line using only whether an observed point lies above or below the line. It changes the slope and y-intercept by small, sign-based amounts rather than using the size of the prediction error. section 3.3
Apply it to one data point at a time:
- Calculate the predicted value from the current slope and y-intercept. section 3.3
- If the observed value is higher than the prediction, increase the slope by learning rate × input and increase the intercept by learning rate. section 3.3
- Otherwise, decrease the slope by learning rate × input and decrease the intercept by learning rate. section 3.3
Moving a house-price line
For a house-price model, a point above the line asks the line to rotate and move upward; a point below it asks the line to rotate and move downward. Repeating these small corrections gradually produces a better-fitting line. section 3.3
Figure 3.6 An illustration of the linear regression algorithm. We start at the top left with a random line and end in the bottom left with a line that fits the dataset well. At each stage, two things happen: (1) we pick a random point, and (2) the point asks the line to move closer to it. After many iterations, the line will be in a good position. This figure has only three iterations for illustrative purposes, but in real life, many more iterations are needed.
Visualizes the repeated process of selecting a point and moving a random line closer to the dataset. section 3.3
