2
$\begingroup$
confusion_matrix(y_test1, pred)
That is my codes 

Confusion matrix, without normalization
True     [[724258    438]
value    [ 25396    302]]
          Predicted value

I understand that is how this is the confusion matrix. But I do not know the order of classification result.

0   [[724258    438]                1 [[724258    438]
1   [ 25396    302]]                0 [ 25396    302]]
       0         1                        1        0

Which order generally? I check the documentation, it does not tell me the specific result.

$\endgroup$
1
$\begingroup$

it's the first one

0   [[724258    438]       
1   [ 25396    302]]      
       0         1  

According to the documentation

sklearn.metrics.confusion_matrix(y_true, y_pred, labels=None, sample_weight=None) 

labels : array, shape = [n_classes], optional List of labels to index the matrix. This may be used to reorder or select a subset of labels. If none is given, those that appear at least once in y_true or y_pred are used in sorted order.

$\endgroup$
  • $\begingroup$ I am also curious what Happen if it is three labels such as 0, 1, 2. Will still follow like that? $\endgroup$ – Tom May 10 '18 at 18:08
  • $\begingroup$ yup, "If none is given, those that appear at least once in y_true or y_pred are used in """"sorted order""""" $\endgroup$ – Fadi Bakoura May 10 '18 at 18:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.