Code for confusion matrix generation