Added predict function.
Calculating accuracy of predictions on the training set.