peal.visualization.model_comparison

Side-by-side comparison grids of several models on the same samples.

Samples are bucketed by a set of binary criteria (e.g. class, presence of a confounder); one representative per bucket is picked from the dataset and every model listed in columns is explained on it, either with LRP heatmaps (LRPExplainer) or with counterfactuals (CounterfactualExplainer). The result is rendered into a single image by peal.visualization.image_grid.make_image_grid with checkbox columns that show which criteria hold for each row.

Functions

change_all

Build the indicator tensor of one criterion over all criterion combos.

create_checkbox_dict

Enumerate all combinations of binary criteria as checkbox columns.

create_comparison

Pick one sample per criterion combination and explain it with each model.

get_explanation

Explain every row of X with one model and return grid columns.