A Weighted Sum for Numbers
Predict a continuous quantity
Linear regression predicts a numeric target as an intercept plus a weighted sum of features. With one feature it fits a line; with many features it fits a flat surface in higher dimensions. Each learned coefficient describes the predicted target change for a one-unit feature increase while other included features stay fixed.
predicted_latency = 18 + 0.7×queue_depth + 4.2×dependency_errors
Training commonly minimizes mean squared error, the average squared difference between prediction and truth. Squaring makes larger mistakes count disproportionately. The closed-form mathematics is useful, but scikit-learn handles fitting directly.
from sklearn.linear_model import LinearRegression
model = LinearRegression()
model.fit(X_train, y_train)
print(model.intercept_, model.coef_)
pred = model.predict(X_test)
Analogy: Imagine adjusting the tilt and height of a rigid sheet so it lies as close as possible to a cloud of points. The sheet cannot bend, which is both the model's clarity and its limitation.
Scenario: A capacity planner estimates CPU demand from request rate and active users. A linear model provides a transparent baseline whose coefficients can be checked against engineering expectations before a more flexible model is justified.