Skip to content

plot_correlation


method plot_correlation(columns=None, method="pearson", title=None, legend=None, figsize=(800, 700), filename=None, display=True)[source]
Plot a correlation matrix.

Displays a heatmap showing the correlation between columns in the dataset. The colors red, blue and white stand for positive, negative, and no correlation respectively.

Parameterscolumns: slice, sequence or None, default=None
Columns to plot. If None, plot all columns in the dataset. Selected categorical columns are ignored.

method: str, default="pearson"
Method of correlation. Choose from: pearson, kendall or spearman.

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

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

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

filename: str 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.

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


See Also

plot_distribution

Plot column distributions.

plot_qq

Plot a quantile-quantile plot.

plot_relationships

Plot pairwise relationships in a dataset.


Example

>>> from atom import ATOMClassifier
>>> from sklearn.datasets import load_breast_cancer

>>> X, y = load_breast_cancer(return_X_y=True, as_frame=True)

>>> atom = ATOMClassifier(X, y)
>>> atom.plot_correlation()