1unique_label = np.unique([y_true, y_pred])
2cmtx = pd.DataFrame(
3 confusion_matrix(y_true, y_pred, labels=unique_label),
4 index=['true:{:}'.format(x) for x in unique_label],
5 columns=['pred:{:}'.format(x) for x in unique_label]
6)
7print(cmtx)
8# Output:
9# pred:no pred:yes
10# true:no 3 0
11# true:yes 2 1
1import pandas as pd
2cmtx = pd.DataFrame(
3 confusion_matrix(y_true, y_pred, labels=['yes', 'no']),
4 index=['true:yes', 'true:no'],
5 columns=['pred:yes', 'pred:no']
6)
7print(cmtx)
8# Output:
9# pred:yes pred:no
10# true:yes 1 2
11# true:no 0 3