Multiple Linear Regression — ML Technical Interview Questions & Answers

Regression with more than one input feature.

Multiple Linear Regression

  • Simple meaning: Same idea as linear regression, but more than one input. marks ≈ b + w1×hours + w2×attendance + w3×sleep. Still a “flat sheet” in higher dimensions, not a curve unless you add extra columns.
  • Picture: Two students with the same hours but different attendance can get different predicted marks. Each weight is “holding other features fixed”.
  • Watch collinearity: hours and “minutes studied” are almost the same column — weights become wild and hard to explain. Drop or combine them.
  • Trap: reading one weight as “the only cause” when features move together. Trap: not scaling if you compare weight sizes (units differ).

Technical Interview Tip: Several inputs, still a linear mix. Check duplicate columns.

Code Examples for Multiple Linear Regression

Multiple Linear Regression — working example

# y ≈ 2x + 1
xs = [1, 2, 3, 4]
ys = [3, 5, 7, 9]
pred = [2 * x + 1 for x in xs]
mse = sum((y - p) ** 2 for y, p in zip(ys, pred)) / len(ys)
mae = sum(abs(y - p) for y, p in zip(ys, pred)) / len(ys)
print(pred, mse, mae)

Multiple Linear Regression — regression predicts continuous values; MSE squares errors, MAE uses absolute errors.

How to Explain Multiple Linear Regression to an Interviewer

Multiple vs simple linear?

More than one feature Same straight-line idea

Collinearity?

Features that duplicate each other Unstable weights