Scikit confusion matrix mismatches the true labels

Viewed 65

I have the following code:

fig, ax = plt.subplots(figsize=(15, 15))
plot_confusion_matrix(clf, X_test, y_test, ax=ax)  
print(pd.Series(y_test).value_counts().sort_index())

The output is shown below. What I don't understand is why the unique values of y_test do not match the True Label in the confusion matrix. For example, 46 to 50 are missing, as well as e.g. 20. Those values do appear in y_test but not in the confusion matrix. Why could this be? I referenced the manual but can't understand why it happens. confusion matrix

10      1
20      2
23      1
26      1
28      2
29      1
30     19
31      3
32     13
33     10
34     31
35     39
36     99
37    131
38    287
39    321
40    499
41    501
42    644
43    438
44    382
45    214
46    113
47     45
48     29
49      3
50     21
dtype: int64
0 Answers
Related