plots Package

plots Package

These functions can be imported from the pyanno.plots namespace. If you use them in an IPython shell, remember to use the magic command %gui to enable the GUI toolkits.

pyanno.plots.pyanno_plots.plot_pairwise_statistics(stat_func, annotations, nclasses=None, **kwargs)[source]

Plot a matrix representation of a statistical function of annotations.

The function stat_func is applied to the annotations of all pairs of annotators, and the resulting matrix is displayed in a window.

Example: ::

>>> plot_pairwise_statistics(pyanno.measures.cohens_kappa, annotations)

See also pyanno.measures.helpers.pairwise_matrix(), plot_square_matrix().

Parameters:
  • stat_func (function) – Function accepting as first two arguments two 1D array of annotations, and returning a single scalar measuring some annotations statistics.
  • annotations (ndarray, shape = (n_items, n_annotators)) – Array of annotations for multiple annotators. Missing values should be indicated by pyanno.util.MISSING_VALUE
  • nclasses (int) – Number of annotation classes. If None, nclasses is inferred from the values in the annotations
  • kwargs (dictionary) – Additional keyword arguments passed to the plot. The argument ‘title’ sets the title of the plot.
pyanno.plots.hinton_plot.plot_hinton_diagram(data, **kwargs)[source]

Display a plot of a Hinton diagram.

This version of the Hinton diagram displays a probability distribution, or any list of numbers between 0 and 1, as a sequence of circles with area proportional to the value of each element.

It can be used to display all 1D parameters of pyAnno models.

Parameters:
  • data (list of floats) – List of numbers between zero and one
  • kwargs (dictionary) – Additional keyword arguments passed to the plot. The argument ‘title’ sets the title of the plot.
pyanno.plots.annotations_plot.plot_posterior(posterior, show_maximum=False, **kwargs)[source]

Display a plot of the posterior distribution over classes.

This function is used together with the infer_labels method offered by all models, e.g.:

>>> from pyanno.models import ModelB
>>> from pyanno.plots import plot_posterior
>>> # create a new model with 3 classes and 6 annotators
>>> model = ModelB.create_initial_state(3, 6)
>>> annotations = model.generate_annotations(100)
>>> # compute the posterior distribution over class labels
>>> posterior = model.infer_labels(annotations)
>>> # plot the distribution in a window
>>> plot_posterior(posterior)
Parameters:
  • posterior (ndarray, shape=(n_annotations, n_classes)) – posterior[i,:] is the posterior distribution over classes for the i-th annotation.
  • show_maximum (bool) – if True, indicate the position of the maxima with white circles
  • kwargs (dictionary) – Additional keyword arguments passed to the plot. The argument ‘title’ sets the title of the plot.
pyanno.plots.theta_plot.plot_theta_parameters(model, theta_samples=None, type='distr', **kwargs)[source]

Display a plot of the annotator accuracy parameters, theta.

This class gives a graphical representation of the theta accuracy parameters for ModelA, ModelBt, and ModelBtLoopDesign.

Parameters:
  • model (instance) – an instance of ModelA, ModelBt, or ModelBtLoopDesignModelBt
  • theta_samples (ndarray, shape = (n_items, n_annotators)) – Samples from the posterior over theta, as returned by the method model.sample_posterior_over_accuracy. If given, they are displayed as a probability distribution superimposed to the values or model.theta.
  • type (string) – Either ‘scatter’ or ‘distr’. Parametrizes two different kind of plots.
  • kwargs (dictionary) – Additional keyword arguments passed to the plot. The argument ‘title’ sets the title of the plot.
pyanno.plots.theta_tensor_plot.plot_theta_tensor(modelB, annotator_idx, theta_samples=None, **kwargs)[source]

Display a plot of model B’s accuracy tensor, theta.

The tensor theta[annotator_idx,:,:] is shown for one annotator as a set of line plots, each depicting the distribution theta[annotator_idx,k,:] = P(annotator_idx outputs : | real class is k).

Parameters:
  • modelB (ModelB instance) – An instance of ModelB.
  • annotator_idx (int) – Index of the annotator for which the parameters are displayed.
  • theta_samples (ndarray, shape = (n_samples x n_annotators x n_classes x n_classes)) – Array of samples over the posterior of theta.
  • kwargs (dictionary) – Additional keyword arguments passed to the plot. The argument ‘title’ sets the title of the plot.
Returns:

theta_view (ThetaTensorPlot instance) - Reference to the plot.

pyanno.plots.matrix_plot.plot_square_matrix(matrix, **kwargs)[source]

Plot a square matrix using a color code.

Parameters:
  • matrix (ndarray, shape = (n, n)) – Square array of numberical values.
  • kwargs (dictionary) – Additional keyword arguments passed to the plot. The argument title sets the title of the plot. The arguments colormap_low and colormap_high set the lowest and highest value for the color map.

Table Of Contents

Previous topic

database Module

This Page