plot_confusion_matrix

besca.tl.plot_confusion_matrix(y_true, y_pred, classes, celltype, name_prediction='auto_annot', normalize=False, title=None, numbers=False, cmap=<matplotlib.colors.LinearSegmentedColormap object>, adata_predicted=None, asymmetric_matrix=True)[source]

plots confusion matrices

returns a matplotlib confusion matrix

Parameters:
  • y_true (pandas.core.series.Series) – ordered series of all true labels

  • y_pred (pandas.core.series.Series) – ordered series of all predicted celltypes

  • classes (numpy.ndarray) – union of true and predictable celltypes

  • celltype (str) – celltype column on which the prediction was performed

  • name_prediction ("auto_annot"| default = "auto_annot") – observation name containing the prediction to compare with.

  • normalize (bool | default = False) – whether to return absolute values or to value all celltypes equally

  • title (str | default = None) – title to be given to confusion matrix figure in file.

  • numbers (`bool`| default = False) – should the numbers be displayed in the plot. Note: is illegible in larger plots

  • cmap (matplotlib.cm | default = plt.cm.Blues) – colour to be used for plotting

  • asymmetric_matrix (bool | default = True) – if False returns square confusion matrix, if True it only shows possible combinations

Returns:

plot of confusion matrix

Return type:

matplotlib.pyplot.plot