Skip to content

plot_wordcloud


method plot_wordcloud(rows="dataset", title=None, legend=None, figsize=(900, 600), filename=None, display=True, **kwargs)[source]
Plot a wordcloud from the corpus.

The text for the plot is extracted from the column named corpus. If there is no column with that name, an exception is raised.

Parametersrows: hashable, segment, sequence or dataframe, default="dataset"
Selection of rows in the corpus to include in the wordcloud.

title: str, dict or None, default=None
Title for the plot.

legend: str, dict or None, default=None
Do nothing. Implemented for continuity of the API.

figsize: tuple, default=(900, 600)
Figure's size in pixels, format as (x, y).

filename: str, Path or None, default=None
Save the plot using this name. Use "auto" for automatic naming. The type of the file depends on the provided name (.html, .png, .pdf, etc...). If filename has no file type, the plot is saved as html. If None, the plot is not saved.

display: bool or None, default=True
Whether to render the plot. If None, it returns the figure.

**kwargs
Additional keyword arguments for the Wordcloud object.

Returnsgo.Figure or None
Plot object. Only returned if display=None.


See Also

plot_ngrams

Plot n-gram frequencies.

plot_pipeline

Plot a diagram of the pipeline.


Example

>>> import numpy as np
>>> from atom import ATOMClassifier
>>> from sklearn.datasets import fetch_20newsgroups

>>> X, y = fetch_20newsgroups(
...     return_X_y=True,
...     categories=["alt.atheism", "sci.med", "comp.windows.x"],
...     shuffle=True,
...     random_state=1,
... )
>>> X = np.array(X).reshape(-1, 1)

>>> atom = ATOMClassifier(X, y, random_state=1)
>>> atom.textclean()
>>> atom.textnormalize()
>>> atom.plot_wordcloud()