attribench.plot.InterMethodCorrelationPlot

class attribench.plot.InterMethodCorrelationPlot(dfs)[source]

Bases: Plot

Heatmap showing Spearman correlations between methods.

Parameters:
dfsDict[str, Tuple[pd.DataFrame, bool]]

A dictionary mapping metric names to tuples of dataframes and booleans. The boolean indicates whether higher values of the metric are better (True) or not (False). The dataframes should have the same columns, which are the names of the methods.

Methods

render

Render the plot.

render_all

Render a separate heatmap for each metric.

render(title=None, figsize=(20, 20), fontsize=None, annot=False)[source]

Render the plot. Spearman correlation values are averaged across metrics. To plot inter-method correlations for each metric separately, use render_all().

Parameters:
titlestr | None, optional

Title of the figure, by default None

figsizeTuple[int, int], optional

Size of the figure, by default (20, 20)

fontsizeint | None, optional

Font size of x and y axis ticks, by default None

annotbool, optional

Whether to annotate the heatmap with the correlation values, by default False

Returns:
Figure

The rendered Matplotlib figure.

Return type:

Figure

render_all(figsize=(20, 20), fontsize=None, annot=False)[source]

Render a separate heatmap for each metric. TODO test and make sure args are consistent with render.

Parameters:
figsizeTuple[int, int], optional

Size of the figures, by default (20, 20)

fontsizeint | None, optional

Font size of x and y axis ticks, by default None

annotbool, optional

Whether to annotate the heatmaps with the correlation values, by default False

Returns:
Dict[str, Figure]

Dictionary mapping metric names to rendered Matplotlib figures.

Return type:

Dict[str, Figure]