skbel.goggles

This package contains the skbel.goggles module, which provides some useful visualizations for the skbel package.

skbel.goggles.visualization

Some visualization utilities.

skbel.goggles.visualization._cca_plot(X_scores, Y_scores, X_obs: array = None, Y_obs: array = None, samples=None, sdir: str = None, show: bool = False, annotation_callback=None, mode=None)[source]

Plot the Canonical Variate Pairs.

Parameters:
  • mode – mode of inference

  • X_scores – Canonical variates for X

  • Y_scores – Canonical variates for Y

  • X_obs – The X observations.

  • Y_obs – The Y observations.

  • samples – The samples to plot.

  • sdir – The directory to save the plot to.

  • show – Whether to show the plot.

  • annotation_callback – A callback function to annotate the plot.

skbel.goggles.visualization._despine(fig=None, ax=None, top=True, right=True, left=False, bottom=False, offset=None, trim=False)[source]

Remove the top and right spines from plot(s).

Parameters:
  • fig – Figure to despine all axes of, defaults to the current figure.

  • ax – Specific axes object to despine. Ignored if fig is provided.

  • bottom (top, right, left,) – If True, remove that spine.

  • offset – Absolute distance, in points, spines should be moved away from the axes (negative values move spines inward). A single value applies to all spines; a dict can be used to set offset values per side.

  • trim – If True, limit spines to the smallest and largest major tick on each non-despined axis.

skbel.goggles.visualization._my_alphabet(az: int)[source]

Method used to make custom figure annotations.

Parameters:

az – Index of the alphabet

Returns:

corresponding letter

skbel.goggles.visualization._proxy_annotate(annotation: list = None, loc: int = 1, fz: float = 11, obj=None)[source]

Places annotation (or title) within the figure box.

Parameters:
  • annotation – Must be a list of labels even of it only contains one label. Savvy ?

  • fz – Font size

  • loc – Location (default: 1 = upper right corner, 2 = upper left corner)

skbel.goggles.visualization._proxy_legend(legend1: legend = None, colors: list = None, labels: list = None, loc: int = 4, marker: list = None, pec: list = None, fz: float = 11, fig_file: str = None, extra: list = None, obj=None)[source]

Add a second legend to a figure @ bottom right (loc=4) https://stackoverflow.com/questions/12761806/matplotlib-2-different-legends-on-same-graph

Parameters:
  • legend1 – First legend instance from the figure

  • colors – List of colors

  • labels – List of labels

  • loc – Position of the legend

  • marker – Points ‘o’ or line ‘-’

  • pec – List of point edge color, e.g. [None, ‘k’]

  • fz – Fontsize

  • fig_file – Path to figure file

  • extra – List of extra elements to be added on the final figure

skbel.goggles.visualization._yield_alphabet(start=0)[source]

Yields the alphabet from a given index.

Parameters:

start – Index of the first letter

skbel.goggles.visualization.cca_vision(X_scores=None, Y_scores=None, X_obs: array = None, Y_obs: array = None, samples=None, n_cut=None, cplot=True, annotation_call=None, fig_dir: str = None, show: bool = False)[source]

Visualize the CCA results.

Parameters:
  • X_scores – CCA scores for X

  • Y_scores – CCA scores for Y

  • X_obs – X observations

  • Y_obs – Y observations

  • samples – Samples from the model

  • n_cut – Only show the first n_cut components

  • cplot – Plot the CCA correlation coefficients

  • annotation_call – Annotation callback

  • fig_dir – Base directory path

  • show – Show figure

skbel.goggles.visualization.explained_variance(n_components, evr, n_cut: int = 0, annotation: list = None, fig_file: str = None, show: bool = False, **kwargs)[source]

PCA explained variance plot.

Parameters:
  • n_components – Number of components

  • evr – Explained variance ratio

  • n_cut – Number of components to display

  • annotation – List of annotation(s)

  • fig_file – Path to figure file

  • show – Show figure

skbel.goggles.visualization.pca_scores(training: array, prediction: array = None, pc_post: array = None, random_pcs: array = None, n_comp: int = 0, annotation: list = None, title: str = None, xlabel: str = None, ylabel: str = None, fig_file: str = None, add_legend: bool = True, show: bool = False)[source]

PCA scores plot, displays scores of observations above those of training.

Parameters:
  • pc_post – PCA scores of the posterior

  • training – Training scores

  • prediction – Test scores

  • pc_post – PCA scores of the posterior (Y)

  • random_pcs – Random PCA scores

  • n_comp – How many components to show

  • annotation – List of annotation(s)

  • title – Title of the plot

  • xlabel – Label of the x axis

  • ylabel – Label of the y axis

  • fig_file – Path to figure file

  • add_legend – Add legend

  • show – Show figure