Visualize

Plot PID

class imml.visualize.plot_pid(rus=None, Xs=None, y=None, modalities: list = ['Modality A', 'Modality B'], colors: list = ['#780000', '#669BBC', '#FDF0D5'], abb: bool = True, figsize: tuple = None, **kwargs)[source]

Bases:

Plot PID statistics (redundancy, uniqueness and synergy) of a multi-modal dataset as a Venn diagram.

Parameters:
  • rus (list or dict, default=None) -- The output of the `̀`̀pid̀̀̀̀`̀`̀ function.

  • Xs (list of array-likes objects, default=None) --

    • Xs length: n_mods

    • Xs[i] shape: (n_samples, n_features_i)

    A list of different modalities. If rus is provided, it will not be used.

  • y (array-like of shape (n_samples,), default=None) -- Target vector relative to Xs. If rus is provided, it will not be used.

  • modalities (list, default=["Modality A", "Modality B"]) -- Name of each modality.

  • colors (list, default=["#780000", "#669BBC", "#FDF0D5"]) -- Colors used for the regions.

  • abb (bool, default=True) -- Whether to use abbreviations (S, U1, U2 and R) for "Synergy", "Uniquesness1", "Uniqueness2" and "Redundancy", respectively.

  • figsize (tuple, default=None) -- Figure size (tuple) in inches.

  • **kwargs (dict, default=None) -- Additional keyword arguments are passed to the pid function.

Returns:

  • fig (matplotlib.figure.Figure) -- Figure object.

  • ax (matplotlib.axes.Axes) -- Axes object.

Examples

>>> import numpy as np
>>> import pandas as pd
>>> Xs = [pd.DataFrame(np.random.default_rng(42).random((20, 10))) for i in range(3)]
>>> y = pd.Series(np.random.default_rng(42).uniform(low=0, high=2, size=len(Xs[0])))
>>> plot_pid(Xs = Xs, y=y, **{"random_state":42})

Plot Missing Modality

class imml.visualize.plot_missing_modality(Xs, ax: Axes = None, figsize: tuple = None, sort: bool = True)[source]

Bases:

Plot modality missing. Missing modalities appear as white, while black indicates available modalities.

Parameters:
  • Xs (list of array-likes objects, default=None) --

    • Xs length: n_mods

    • Xs[i] shape: (n_samples, n_features_i)

    A list of different modalities. If rus is provided, it will not be used.

  • ax (matplotlib.axes.Axes, default=None) -- Axes where to draw the figure.

  • figsize (tuple, default=None) -- Figure size (tuple) in inches.

  • sort (bool, default=True) -- If True, samples will be sort based on their available modalities.

Returns:

  • fig (matplotlib.figure.Figure) -- Figure object.

  • ax (matplotlib.axes.Axes) -- Axes object.