cc_tk.plot package

Submodules

cc_tk.plot.classification module

Classification plots.

cc_tk.plot.classification.plot_confusion(confusion_matrix: ndarray | DataFrame, fmt: str = 'd', near_diag: int = 1, vrange: Literal['global', 'local'] | Tuple[float] = 'global') None[source]

Plot a confusion matrix with green, blue and red color scales.

Parameters:
  • confusion_matrix (ArrayLike2D) – The confusion matrix to plot.

  • fmt (str) – The format string for the annotations in the heatmap. Default is ‘d’, which corresponds to integers.

  • near_diag (int, optional) – The number of cells near the diagonal to highlight with a different color. Default is 1, which corresponds to the cells immediately adjacent to the diagonal. A value of 0 will include the diagonal cells, and a value of -1 will disable the near-diagonal cells.

  • vrange (Union[Literal['global', 'local'], Tuple[float, float]], optional) – The range of values to use for the color scale. If ‘global’, the range is set to (0, maximum value of the entire confusion matrix). If ‘local’, the range is set to (minimum value of each heatmap, maximum value of each heatmap). If a tuple, the range is set to the given values. Default is ‘global’.

Examples

>>> from cc_tk.plot.classification import plot_confusion
>>> import numpy as np
>>> confusion_matrix = np.array([[15, 3, 1], [2, 10, 0], [0, 0, 5]])
>>> plot_confusion(confusion_matrix, fmt=".2f")

(Source code, png, hires.png, pdf)

../_images/cc_tk-plot-1.png

Module contents

Module for plotting data.