The slope gives the predicted change in the dependent variable for a one-unit increase in the independent variable. The intercept gives the predicted value of the dependent variable when the independent variable equals zero.
In linear regression, a supervised machine learning algorithm fits a line to labelled training data. For one independent variable, the model is:
Here, is the predicted output, is the input feature, is the slope, and is the intercept. During training, the algorithm estimates and , typically by minimizing a loss function such as the mean squared error between predicted and actual values.
| Component | Meaning | Interpretation |
|---|---|---|
| Slope | Rate of change | When increases by one unit, changes by units. A negative value means the prediction decreases. |
| Intercept |
For example, suppose a model predicts compilation time from the number of source-code lines:
The slope means each additional line is associated with an increase of milliseconds in predicted compilation time. The intercept means the model predicts a compilation time of milliseconds when there are zero lines.
The line can also be used for interpolation within the observed data range. However, predictions far beyond that range are extrapolations and may be unreliable because the relationship may change. Neither coefficient alone measures model accuracy; evaluate the loss and test-data performance as well.
A common misconception is that the slope proves causation. It only describes the relationship learned from the training data; it does not prove that changing directly causes the change in .
Exam technique: For an IB Computer Science A4.3 question, state both the numerical value and its contextual meaning, including units. Use “predicted” rather than claiming the model gives an exact result, and identify whether the slope indicates a positive or negative relationship.