Hey I have a quick question about my workflow with a problem.
I am writing a little logistic regression function for Andrew Ng’s ML course on coursera. I have X
and y
, where y is 0 or 1. I want to make sure that the scopes I am using are correct
function logit(X, y)
function costFunction(theta)
cost = f(theta, X, y) # X and y are only available to this function, so they are type stable
return cost
end
theta_0 = [0, 0, 0] # X has width of 3, for example
theta = optimize(costFunction, theta_0) # not the complete code or correct syntax
return theta
I am writing this because the course is done in Octave / Matlab. There, the syntax is
[theta, cost] = ...
fminunc(@(t)(costFunction(t, X, y)), initial theta, options);
In Julia, it seems that Optim.jl and JuMP don’t allow your function to take in anything other than your parameters of interest, so having X
and y
in the cost function wouldn’t work. This has to do with the way Julia optimizes for the types of variables, so my procedure above is the Julian way of working with this problem.
Is my understanding correct?
PS perhaps this should be in gitter? I just want to ensure I have the right understanding.