When to Reach for Linear Regression
Prefer the simple model when its shape fits
Linear regression is fast, memory-light, interpretable, and a strong baseline for numeric prediction. It extrapolates beyond the observed target range, which can be useful when the relationship remains linear and dangerous when it does not. It also struggles with sharp thresholds and interactions unless you explicitly add transformed features.
A polynomial feature such as temperature² lets a linear model represent curvature; an interaction feature such as traffic × cache_miss_rate lets one feature's effect depend on another. Added flexibility can overfit, so transformations belong inside cross-validated pipelines.
from sklearn.preprocessing import PolynomialFeatures
from sklearn.pipeline import make_pipeline
curve = make_pipeline(PolynomialFeatures(degree=2), LinearRegression())
Tip: Start here when the target is numeric, data is modest, explanation matters, and a roughly additive relationship is plausible. Compare with tree ensembles when strong thresholds and interactions dominate.
Warning: Never trust far-range extrapolation without domain constraints. A fitted line can predict negative demand or impossible percentages because it does not know physical boundaries.