psiz.mplot

Module of plotting functionality based on matplotlib.

psiz.mplot.bvn_ellipse(loc, cov, r=1.96, **kwargs)

Return ellipse object representing bivariate normal.

This code was inspired by a solution posted on Stack Overflow: https://stackoverflow.com/a/25022642/1860294

Parameters
  • loc – A 1D array denoting the mean.

  • cov – A 2D array denoting the covariance matrix.

  • r (optional) – The radius (specified in standard deviations) at which to draw the ellipse. The default value corresponds to an ellipse indicating a region containing 95% of the highest probability mass (i.e, HDI). Another common value is 2.576, which indicates 99%.

  • kwargs (optional) – Additional key-word arguments to pass to matplotlib.patches.Ellipse constructor.

Returns

A matplotlib.patches.Ellipse artist object.

Return type

ellipse

psiz.mplot.embedding_input_dimension(embedding, idx, ax=None, c='b')

Visualize embedding values for a requested input dimension.

Plots point estimates of embedding values for the requested input dimension.

If the embedding layer is a distribution, also attempts to draw a thick linewidth interval indicating the middle 50% probability mass and a thin linewidth interval indicating the middle 99% probability mass via the inverse CDF function.

Intended to handle rank 2 embeddings.

Parameters
  • embedding – An embedding layer.

  • idx – Index of requested input dimension to visualize.

  • ax (optional) – A ‘matplotlib’ AxesSubplot object.

  • c (optional) – Color of interval marks.

psiz.mplot.embedding_output_dimension(embedding, idx, ax=None, c='b')

Visualize all embedding values for a requested output dimension.

Plots point estimates of embedding values for the requested output dimension.

If the embedding layer is a distribution, also attempts to draw a thick linewidth interval indicating the middle 50% probability mass and a thin linewidth interval indicating the middle 99% probability mass via the inverse CDF function.

Intended to handle rank 2 embeddings.

Parameters
  • embedding – An embedding layer.

  • idx – Index of requested output dimension to visualize.

  • ax (optional) – A ‘matplotlib’ AxesSubplot object.

  • c (optional) – Color of interval marks.

psiz.mplot.hdi_bvn(loc, cov, ax=None, p=0.99, **kwargs)

Plot HDI of bivariate normal distributions.

Ellipses are drawn to indicate the higest density interval.

Parameters
  • loc – Array denoting the means of bivariate normal distributions. shape=(n_distribution, 2)

  • cov – Array denoting the covariance matrices of bivariate normal distributions. shape=(n_distribution, 2, 2)

  • ax (optional) – A ‘matplotlib’ AxesSubplot object.

  • p (optional) – The amount of probability that the HDI should indicate. This must be a float ]0, 1[.

  • kwargs (optional) – Additional key-word arguments that will be passed to a matplotlib.patches.Ellipse constructor. NOTE: Any values that have a __len__ property with be inspected to see if the length matches the number of distributions. If so, it will be assumed that these are values that should be applied on a per-distribution bases. For example, if edgecolor has shape=(n_distribution, 3), it will be assumed that the edgecolor[i_distr] should be applied to the ith distribution.

psiz.mplot.heatmap_embeddings(embedding, ax=None, cmap=None)

Visualize embeddings as a heatmap.

Intended to handle rank 2 embeddings.

Parameters
  • embedding – An embedding layer.

  • ax (optional) – A ‘matplotlib’ AxesSubplot object.

  • cmap (optional) – A Matplotlib compatible colormap.