5 hidden checks
Implement ridge regression and the polynomial features to try it on.
poly_features(x, degree): for a 1-D arrayx, return an array of shape(len(x), degree)with columns (no constant column).ridge_fit(X, y, lam): return(w, b)minimising , without penalisingb. Trick: centreXandy(subtract their means), solve , thenb = y.mean() - X.mean(axis=0) @ w.
- 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