uadapy.plotting.shepard_diagram module
- uadapy.plotting.shepard_diagram.custom_wasserstein(dist1, dist2)
- uadapy.plotting.shepard_diagram.load_iris()
- uadapy.plotting.shepard_diagram.plot_shepard_diagram(distributions_hi, distributions_lo, n_samples=1000, seed=55, metric='kl', labels=None, show_plot=False)
Plot a Shepard diagram to assess how well pairwise distances between distributions in a high-dimensional space are preserved in a reduced (low-dimensional) space. Supports predefined or custom distance metrics.
- Parameters:
distributions_hi (list of uadapy.Distribution or uadapy.Distribution) – The original (high-dimensional) distributions.
distributions_lo (list of uadapy.Distribution or uadapy.Distribution) – The reduced (low-dimensional) distributions obtained via dimensionality reduction.
n_samples (int, optional) – Number of samples to draw per distribution when using sample-based distance metrics. Default is 10000.
seed (int, optional) – Seed for the random number generator to ensure reproducibility of sampling. Default is 55.
metric (str or callable, optional) –
Distance metric to use for computing pairwise distances between distributions. If a string, choose from: - “kl” : KL divergence between Gaussian approximations. - “wasserstein” : Average Wasserstein distance across dimensions. - “mean” : Euclidean distance between distribution means. If a callable, it must accept the following arguments:
dist1: uadapy.Distribution
dist2: uadapy.Distribution
and return a scalar distance value. Default is “kl”.
labels (list of str, optional) – List of class names for the distributions. If provided, labels like “class A vs class B” will be used to annotate points in the plot. If None, numeric indices will be used.
show_plot (bool, optional) – If True, displays the plot. Default is False.
- Returns:
matplotlib.figure.Figure – The figure object containing the Shepard diagram.
matplotlib.axes.Axes – The Axes object used for the plot.