Reputation: 3854
w = scipy.linalg.inv(X.transpose() * X)* X.transpose() * y;
When I execute the following inside one of my functions.. I get the following error. I'm kind of new to Python and would appreciate any help. Thank you.
ValueError: operands could not be broadcast together with shapes (64,242) (242,64)
Upvotes: 0
Views: 662
Reputation: 282026
*
isn't matrix multiplication*. For matrix multiplication, you should use numpy.dot
or the dot
method of array objects.
w = scipy.linalg.inv(X.T.dot(X)).dot(X.T).dot(y)
*unless you're using the specific class where it is. Don't use that class; it'll produce bigger headaches than you already have.
Upvotes: 2