A simple guide to building a confusion matrix - Oracle The confusion matrix code for train data set is : confmatrix_trainset = confusion_matrix (y_train,predict_train, labels=labels) Changing the position of parameters y_train and predict_train can reverse the position of Actual and Predicted values as shown in Diagram 1. This will change the values of FP and FN.