I am trying to implement logistic regression as per some course on Machine learning. I am using the Atom editor for running Julia.
However i am unable to find the right arguments for using the optimize function.
I am sending my differentiable function which is the costFunction and initial_theta as the initial parameters. What other arguments are needed?
I am attaching my code here.
This is my cost function:
"This function calculates the cost and gradient at a given theta"
function costFunction( initial_theta,X, y)
m = length(y);
J = 0;
grad = zeros(size(initial_theta));
z = X * initial_theta;
h_theta = sigmoid(z);
J = (-1/m) * ( y .* log(h_theta) + (1-y) .* log(1 - h_theta) );
grad = (1/m) * X' * ( h_theta - y );
return J, grad;
end
This is the snippet from my main function:
l() = Optim.DifferentiableFunction(costFunction(initial_theta,X,y))
methodToUse = Optim.GradientDescent()
options = Optim.OptimizationOptions(iterations = 400)
optimize(l,initial_theta) ######### when i do this, i get a stack over flow error
optimize(l,initial_theta, methodToUse,options) ######## with this i get a Method error : no method matching finite_difference