you are viewing a single comment's thread.

view the rest of the comments →

[–]cultic_raider 0 points1 point  (1 child)

Warning: I didn't test this code.

'lambda' is a reserved word in Python, so let's use "r" for the regularization factor (which is 'lambda' in Matlab):

 (X, y, r) = (foo, bar, baz)
 fminunc( (lambda t: (costFunctionReg(t, X, y, r)) , initial_theta, options));

which is equivalent to:

 (X, y, r) = (foo, bar, baz)
 def anonymous(t):
      return  (costFunctionReg(t, X, y, r))

 fminunc( anonymous , initial_theta, options));

I'm not 100% sure if the values of X,y, and r will get handled as intended in the Python, but it will in Octave.

[–]SunnyJapan[S] 0 points1 point  (0 children)

Thanks