Is the code also valid for multi-variable linear regression?

Is the code implementation done by Prateek sir in this tutorial valid even for multivariable linear regression?

Hello Sagnik,
For multivariate regression, our approach changes. This is covered in the coming videos and there are topics assigned to it specifically :slight_smile:

Yes, there is a section on multi-variable linear regression. Where we have used the sklearn library to train the model. Is it that section you are talking abut?

But specifically in this case the algorithm works on matrix representation of the data set.
image

So I expect that this should also work for multi variable linear regression also.

This is the code implementation by Prateek Bhaiya:

def predict(X,theta):

return np.dot(X,theta)

def getThetaClosedForm(X,Y):

Y = np.mat(Y)
firstPart = np.dot(X.T,X)
secondPart = np.dot(X.T,Y)

theta = np.linalg.pinv(firstPart)*secondPart
return theta

I wanted you to check on this code…

Hello Sagnik,
Yes, the Closed Form Solution is applicable to Multivariate cases too.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.