Linear Regression by the Normal Equation

easy
Unit 1 · Regression & Metrics0/3 to milestone

Fit ordinary least squares in closed form. With an intercept column of ones added to X, the coefficients solve

(X⊤X) β=X⊤y(X^\top X)\,\beta = X^\top y

Implement fit_linear(X, y) returning (intercept, coefs) and predict_linear(X, intercept, coefs). Use np.linalg.solve, not an explicit inverse.

#regression#linear-algebra2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Linear Regression by the Normal Equation · TechGradify