#!/usr/bin/env python # coding: utf-8 # In[1]: get_ipython().run_line_magic('matplotlib', 'inline') # # Confusion Matrix # Utility function for visualizing confusion matrices via matplotlib # > `from mlxtend.plotting import plot_confusion_matrix` # ## Overview # ### Confusion Matrix # For more information on confusion matrices, please see [`mlxtend.evaluate.confusion_matrix`](../evaluate/confusion_matrix.md). # ### References # # - - # ## Example 1 - Binary and Multi-Class # In[2]: from mlxtend.plotting import plot_confusion_matrix import matplotlib.pyplot as plt import numpy as np binary = np.array([[4, 1], [1, 2]]) fig, ax = plot_confusion_matrix(conf_mat=binary) plt.show() # In[3]: multiclass = np.array([[2, 1, 0, 0], [1, 2, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) fig, ax = plot_confusion_matrix(conf_mat=multiclass) plt.show() # ## API # In[1]: with open('../../api_modules/mlxtend.plotting/plot_confusion_matrix.md', 'r') as f: s = f.read() print(s) # In[ ]: