I have a pandas DataFrame with multiple columns, where two of them are of type bool and called result
and predict
.
I use the following code to get a multi-indexed series:
df.value_counts()
Which returns:
result | predict | |
---|---|---|
True | True | 886 |
False | 995 | |
False | True | 35 |
False | 28 |
I want to be able to plot this confusion matrix using seaborn or matplotlib.
CodePudding user response:
Rather use crosstab
:
import seaborn as sns
ct = pd.crosstab(df['result'], df['predict'])
print(ct)
sns.heatmap(ct)