Read Residuals, Not Only R²
Errors reveal missing structure
A residual is actual - predicted. A useful linear fit leaves residuals scattered without obvious structure. A curve in residuals suggests nonlinearity; a widening funnel suggests error spread changes with the prediction; extreme points may exert unusual influence.
residuals = y_test - pred
print(pd.DataFrame({'predicted': pred, 'residual': residuals}).head())
Linear regression assumes the mean target can be expressed linearly in the chosen features, observations provide appropriate independent evidence, and extreme collinearity is controlled. Multicollinearity means features carry nearly overlapping information, making individual coefficient estimates unstable even when predictions remain adequate.
Scenario: A coefficient claims each extra server raises latency, but servers are added only during high-traffic periods. The model describes conditional association in this dataset, not the causal effect of adding a server.
Warning: Coefficients are not automatically causal. Omitted variables, selection, and correlated features can change their meaning.