Loading...
Implement Ridge Regression (L2 regularization) using the regularized normal equation.
Given feature matrix X (without bias column), target vector y, and regularization parameter λ, compute: w=(XaTXa+λI′)−1XaTy
where Xa has a column of ones prepended, and I′ is the identity matrix with the top-left element set to 0 (we don't regularize the bias).
Return the weight vector as a list, rounded to 4 decimal places.
X = [[1], [2], [3]] y = [2, 4, 6] lambda_reg = 0.0
[0.0, 2.0]