Corrected and Optimised Cost Function

Corrected error in calculating the cost. Moved the error out of the loop
to only be calculated a single time. Fixed the correct version of X to
be called inside the gradient calculation.
Prediction Function

Prediction function for Logistic Regression