%matplotlib inline
Utility function for visualizing confusion matrices via matplotlib
from mlxtend.plotting import plot_confusion_matrix
For more information on confusion matrices, please see mlxtend.evaluate.confusion_matrix
.
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()
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()
with open('../../api_modules/mlxtend.plotting/plot_confusion_matrix.md', 'r') as f:
s = f.read()
print(s)
## plot_confusion_matrix *plot_confusion_matrix(conf_mat, hide_spines=False, hide_ticks=False, figsize=(2.5, 2.5), cmap=None, alpha=0.3)* Plot a confusion matrix via matplotlib. **Parameters** - `conf_mat` : array-like, shape = [n_classes, n_classes] Confusion matrix from evaluate.confusion matrix. - `hide_spines` : bool (default: False) Hides axis spines if True. - `hide_ticks` : bool (default: False) Hides axis ticks if True - `figsize` : tuple (default: (2.5, 2.5)) Height and width of the figure - `cmap` : matplotlib colormap (default: `None`) Uses matplotlib.pyplot.cm.Blues if `None` **Returns** - `fig, ax` : matplotlib.pyplot subplot objects Figure and axis elements of the subplot.