X : matrix of predictor variables.
Y : vector of the outcome variable.
Specifically, create a Python function LinReg
which can solve for the coefficients of a linear regression model using the normal equations.
def LinReg(X, y):
beta = <insert normal equations here>
return(beta)
hint: Use the function created above to solve the normal equations for linear regression and verify your solution with the standard implementation in scikit-learn
hint: how would you include the intercept (or bias) in the beta matrix?
The Jupyter notebooks or .py scripts are to be uploaded to Github no later than 5pm on last data lab day. Confer with a lecturer beforehand if you're handing in something other than Jupyter notebook or .py scripts.
[1] https://numpy.org/doc/stable/reference/routines.linalg.html
[2] https://numpy.org/doc/stable/reference/generated/numpy.linalg.solve.html