3 hidden checks
Implement the two building blocks of every linear regression.
standardize(X): return(Z, mu, sigma)wheremuandsigmaare the per-column mean and standard deviation ofX(shape(n, d)), andZ = (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 usenp.linalg.lstsqornp.linalg.solveon the normal equation.
- 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