Plotting

Description

The Plotting module provides tools for visualizing images, text, model summaries, and training history. It includes a general Plotter class with common visualization methods and specialized subclasses like BinaryPlotter and MultiClassPlotter for binary and multi-class classification.

Main classes

class Plotter

A base class for plotting images, text, model summaries, and training history.

The Plotter class provides methods for visualizing research attributes, including dataset samples, textual outputs, and model performance.

__init__()

Initializes the Plotter.

plot_text(text: str, **general_plot_kwargs)

Plots the given text.

Parameters:
  • text (str) – The text to be plotted.

  • general_plot_kwargs – Additional plotting arguments. - title (str, optional): Title of the plot. Defaults to “Text”. - show (bool, optional): Whether to show the plot. Defaults to False.

Returns:

(matplotlib.figure.Figure) The figure containing the text.

plot_model_summary(**general_plot_kwargs)

Plots the summary of the given model.

Parameters:

general_plot_kwargs – Additional plotting arguments. - title (str, optional): Title of the plot. Defaults to “Model Summary”. - show (bool, optional): Whether to show the plot. Defaults to False.

Returns:

(matplotlib.figure.Figure) The figure containing the model summary.

plot_training_history(**general_plot_kwargs)

Plots the training history of the model.

Parameters:

general_plot_kwargs – Additional plotting arguments. - title (str, optional): Title of the plot. - show (bool, optional): Whether to show the plot. Defaults to False.

Returns:

(matplotlib.figure.Figure) The figure containing the training history.


class BinaryPlotter

A specialized plotter for binary classification tasks.

The BinaryPlotter extends Plotter to provide visualization tools specifically designed for binary classification problems.

plot_images(grid_size: tuple = (2, 2))

Plots a grid of images from a dataset, labeling them with class names.

Parameters:

grid_size (tuple) – Tuple specifying the grid size as (rows, columns). Defaults to (2,2).

Returns:

(matplotlib.figure.Figure) The figure containing the images.

plot_confusion_matrix(**general_plot_kwargs)

Plots the confusion matrix for binary classification.

Parameters:

general_plot_kwargs – Additional plotting arguments. - title (str, optional): Title of the plot. Defaults to “Confusion Matrix”. - show (bool, optional): Whether to show the plot. Defaults to False.

Returns:

(matplotlib.figure.Figure) The figure containing the confusion matrix.

plot_roc_curve(**general_plot_kwargs)

Plots the Receiver Operating Characteristic (ROC) curve.

Parameters:

general_plot_kwargs – Additional plotting arguments. - title (str, optional): Title of the plot. Defaults to “ROC Curve”. - show (bool, optional): Whether to show the plot. Defaults to False.

Returns:

(matplotlib.figure.Figure) The figure containing the ROC curve.

plot_pr_curve(**general_plot_kwargs)

Plots the Precision-Recall (PR) curve.

Parameters:

general_plot_kwargs – Additional plotting arguments. - title (str, optional): Title of the plot. Defaults to “PR Curve”. - show (bool, optional): Whether to show the plot. Defaults to False.

Returns:

(matplotlib.figure.Figure) The figure containing the PR curve.

plot_results(grid_size: tuple = (2, 2))

Plots the results of a binary classification model.

Parameters:

grid_size (tuple) – Tuple specifying the grid size as (rows, columns). Defaults to (2,2).

Returns:

(matplotlib.figure.Figure) The figure containing the classification results.


class MultiClassPlotter

A specialized plotter for multi-class classification tasks.

The MultiClassPlotter extends Plotter and provides additional visualization tools tailored to multi-class classification.

plot_images(grid_size: tuple = (2, 2), **general_plot_kwargs)

Plots a grid of images from a dataset, labeling them with class names.

Parameters:
  • grid_size (tuple) – Tuple specifying the grid size as (rows, columns). Defaults to (2,2).

  • general_plot_kwargs – Additional plotting arguments. - title (str, optional): Title of the plot. Defaults to “Images”. - show (bool, optional): Whether to show the plot. Defaults to False.

Returns:

(matplotlib.figure.Figure) The figure containing the images.

plot_confusion_matrix(**general_plot_kwargs)

Plots the confusion matrix for multi-class classification.

Parameters:

general_plot_kwargs – Additional plotting arguments. - title (str, optional): Title of the plot. Defaults to “Confusion Matrix”. - show (bool, optional): Whether to show the plot. Defaults to False.

Returns:

(matplotlib.figure.Figure) The figure containing the confusion matrix.

plot_results(grid_size: tuple = (2, 2), prediction_bar: bool = False)

Plots a grid of images with their true and predicted labels.

If prediction_bar is set to True, a bar plot is shown alongside the images displaying the predicted probabilities.

Parameters:
  • grid_size (tuple) – Tuple specifying the grid size as (rows, columns). Defaults to (2,2).

  • prediction_bar (bool) – Whether to show the predicted probabilities as a bar plot. Defaults to False.

Returns:

(matplotlib.figure.Figure) The figure containing the images and labels.