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.
Parameters |
rows: 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
display: bool or None, default=Truefilename has no file type,
the plot is saved as html. If None, the plot is not saved.
Whether to render the plot. If None, it returns the figure.
**kwargs
Additional keyword arguments for the Wordcloud object.
|
Returns | {#plot_wordcloud-go.Figure or None}
go.Figure or None
Plot object. Only returned if display=None .
|
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()