Added code to calculate confusion matrix of training set.