Linear Regression Using Gradient Descent

Linear Models DS practice problem on Onlearn.

Difficulty: easy.

Topics: Understanding Linear Regression Using Gradient Descent, Mean Squared Error, Learning Rate Scheduling, Intercept Bias Term, Partial Derivatives, Floating Point Precision, Linear Algebra, Numerical Optimization, Statistical Modeling, Computational Calculus, Software Engineering, Matrix Operations, Gradient Descent Variants, Loss Function Minimization, Vectorization Techniques, Model Parameter Estimation.

Write a Python function that performs linear regression using gradient descent. The function should take NumPy arrays X (features with a column of ones for the intercept) and y (target) as input, along with learning rate alpha and the number of iterations, and return the coefficients of the linear regression model as a NumPy array. Round your answer to four decimal places. 0.0 is a valid result for rounding a very small number.