Added the logic to compute the confusion matrix