5 hidden checks

Implement ridge regression and the polynomial features to try it on.

  • poly_features(x, degree): for a 1-D array x, return an array of shape (len(x), degree) with columns (no constant column).
  • ridge_fit(X, y, lam): return (w, b) minimising , without penalising b. Trick: centre X and y (subtract their means), solve , then b = y.mean() - X.mean(axis=0) @ w.
checks
  • poly_features has columns x .. x^dnot run
  • ridge_fit with lam = 0 is ordinary least squaresnot run
  • ridge_fit matches the penalised optimumnot run
  • the bias is not penalisednot run
  • weights shrink as lam growsnot run
python sleeps until you press run

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