-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Description
datasciencecoursera/Stanford_Machine_Learning/Week2/Assignment/Python/computeCost.py
Line 25 in 2ab7696
| s = np.power(( X.dot(theta) - np.transpose([y]) ), 2) |
Matlab/Octave:
J = (1/(2*m)) *sum( (((X*theta)-y).^2))
Python :
s = np.power(( X.dot(theta) - np.transpose([y]) ), 2)
J = (1.0/(2*m)) * s.sum( axis = 0 )
They look equivalent except the python has that np.transpose([y])
Why is it needed?
BTW, My Octave version of this cost function is the same as yours.
This is probably not a bug, but it is confusing. You've done a nice job of doing the Python version. It would be an improvement to at least comment on that. I really wanted to do the assignment in NumPy, but Ng's tutorial on Matlab was so easy to follow that I just did the Octave version. Now I can compare the syntax. A Tabla Rosa!
Metadata
Metadata
Assignees
Labels
No labels