Linear Regression Using Normal Equation

Linear Models DS practice problem on Onlearn.

Difficulty: easy.

Topics: Understanding Linear Regression Using Normal Equation, Moore-Penrose Pseudoinverse, Normal Equation, Matrix Inversion, Gram Matrix, Rounding Precision, Linear Algebra, Statistical Modeling, Numerical Analysis, Computational Complexity, Optimization Theory, Matrix Decompositions, Ordinary Least Squares, Vectorized Operations, Floating Point Arithmetic, Closed-Form Solutions.

Write a Python function that performs linear regression using the normal equation. The function should take a matrix X (features) and a vector y (target) as input, and return the coefficients of the linear regression model. Round your answer to four decimal places, 0.0 is a valid result for rounding a very small number.