plsa.visualize module

class plsa.visualize.Visualize(result: plsa.algorithms.result.PlsaResult)

Bases: object

Visualize the results of probabilistic latent semantic analysis.

Parameters:result (PlsaResult) – The results object returned by the fit method of a PLSA model object.
convergence(axis: matplotlib.axes._subplots.AxesSubplot) → List[matplotlib.lines.Line2D]

Plot the convergence of the PLSA run.

The quantity to be minimized is the Kullback-Leibler divergence between the original document-word matrix and its approximation given by the (conditional) PLSA factorization.

Parameters:axis (Subplot) – The matplotlib axis to plot into.
Returns:The line object plotted into the given axis.
Return type:list of Line2D
prediction(doc: str, axis: matplotlib.axes._subplots.AxesSubplot) → matplotlib.container.BarContainer

Plot the predicted relative weights of topics in a new document.

Parameters:
  • doc (str) – A new document given as a single string.
  • axis (Subplot) – The matplotlib axis to plot into.
Returns:

The container for the bars plotted into the given axis.

Return type:

BarContainer

topics(axis: matplotlib.axes._subplots.AxesSubplot) → matplotlib.container.BarContainer

Plot the relative importance of the individual topics.

Parameters:axis (Subplot) – The matplotlib axis to plot into.
Returns:The container for the bars plotted into the given axis.
Return type:BarContainer
topics_in_doc(i_doc: int, axis: matplotlib.axes._subplots.AxesSubplot) → matplotlib.container.BarContainer

Plot the relative weights of topics in a given document.

Parameters:
  • i_doc (int) – Index of the document to plot. Numbering starts at 0.
  • axis (Subplot) – The matplotlib axis to plot into.
Returns:

The container for the bars plotted into the given axis.

Return type:

BarContainer

wordclouds(figure: matplotlib.figure.Figure) → List[matplotlib.image.AxesImage]

Plot the relative importance of words in all topics.

Parameters:figure (Figure) – An empty matplotlib figure to plot into.
Returns:List of images with the created word clouds.
Return type:list of AxisImage
words_in_topic(i_topic: int, axis: matplotlib.axes._subplots.AxesSubplot) → matplotlib.image.AxesImage

Plot the relative importance of words in a given topic.

Parameters:
  • i_topic (int) – Index of the topic to plot. Numbering starts at 0.
  • axis (Subplot) – The matplotlib axis to plot into.
Returns:

The image with the produced word cloud.

Return type:

AxesImage