I get the confusion matrix but since my actual data set has lot of classification categories, it's difficult to understand.
Example -
>>> from sklearn.metrics import confusion_matrix
>>> y_test
['a', 'a', 'b', 'c', 'd', 'd', 'e', 'a', 'c']
>>> y_pred
['b', 'a', 'b', 'c', 'a', 'd', 'e', 'a', 'c']
>>>
>>>
>>> confusion_matrix(y_test, y_pred)
array([[2, 1, 0, 0, 0],
[0, 1, 0, 0, 0],
[0, 0, 2, 0, 0],
[1, 0, 0, 1, 0],
[0, 0, 0, 0, 1]], dtype=int64)
But how to print the labels/column names for better understanding?
I even tried this -
>>> pd.factorize(y_test)
(array([0, 0, 1, 2, 3, 3, 4, 0, 2], dtype=int64), array(['a', 'b', 'c', 'd', 'e'], dtype=object))
>>> pd.factorize(y_pred)
(array([0, 1, 0, 2, 1, 3, 4, 1, 2], dtype=int64), array(['b', 'a', 'c', 'd', 'e'], dtype=object))
Any help please?
Try something like this:
Output: