calour.training.plot_cm

calour.training.plot_cm(result, normalize=False, title='confusion matrix', cmap=None, ax=None, classes=None, **kwargs)[source]

Plot confusion matrix

Parameters:
  • result (pandas.DataFrame) – data frame containing predictions per sample (in row). It must have a column of true class named “Y_TRUE”. It must have a column of predicted class named “Y_PRED” or multiple columns of predicted probabilities for each class. It typically takes the output of classify().
  • normalize (bool) – normalize the confusion matrix or not
  • title (str) – plot title
  • cmap (str or matplotlib.colors.ListedColormap) – str to indicate the colormap name. Default is “Blues” colormap. For all available colormaps in matplotlib: https://matplotlib.org/users/colormaps.html
  • ax (matplotlib.axes.Axes or None (default), optional) – The axes where the confusion matrix is plotted. None (default) to create a new figure and axes to plot the confusion matrix
  • classes (list) – The list of the labels you want to include in the plot in the order specified in the list.
  • kwargs (dict) – keyword argument passing to matplotlib.pyplot.imshow(). For example, you can pass vmin=0, vmax=1 as keyword arguments to manually define color range (especially useful when you set normalize=True)
Returns:

The axes for the confusion matrix

Return type:

matplotlib.axes.Axes