Loading...
Implement multiple linear regression using the normal equation.
Given a feature matrix X (without bias column) and target vector y, compute the weight vector w that minimizes the mean squared error.
First, prepend a column of ones to X to form the augmented matrix Xa, then solve: w=(XaTXa)−1XaTy
Return the weight vector as a list, rounded to 4 decimal places. The first element is the bias/intercept.
You must implement matrix operations from scratch (transpose, multiply, invert).
X = [[1], [2], [3]] y = [2, 4, 6]
[0.0, 2.0]