3 hidden checks

Implement the two building blocks of every linear regression.

  • standardize(X): return (Z, mu, sigma) where mu and sigma are the per-column mean and standard deviation of X (shape (n, d)), and Z = (X - mu) / sigma.
  • fit_linear(X, y): return (w, b), the least-squares weights (shape (d,)) and bias (a float). Add a column of ones and use np.linalg.lstsq or np.linalg.solve on the normal equation.
checks
  • standardize gives mean 0, std 1 per columnnot run
  • fit_linear recovers known weightsnot run
  • fit_linear matches numpy's least squares on noisy datanot run
python sleeps until you press run

Press Run & check. Your code runs first, then the hidden checks on the left.