peal.visualization.model_comparison.create_comparison¶
- peal.visualization.model_comparison.create_comparison(explainer, dataset, criterions, columns, score_reference_idx, device, max_samples=100000000, checkbox_dict_in=None, batch_size=1)[source]¶
Pick one sample per criterion combination and explain it with each model.
The dataset is scanned from index 50 onwards; the first sample matching each combination of
criterionsis kept together with every model’s softmax score forscore_reference_idx. Thenget_explanationis called per column and the whole thing is rendered as one image.- Parameters:
explainer (
LRPExplainerorCounterfactualExplainer) – Reused for all columns; itspredictoris swapped per column.dataset (
peal dataset) – Indexable dataset returning(x, y).criterions (
dict) –{name: callable(x, y) -> bool}defining the row buckets.columns (
dict) –{column_name: (explanation_type, model, target_key, base_path)};modelis called onx.unsqueeze(0).to(device).score_reference_idx (
int) – Class index whose softmax score is reported per row.device (
strortorch.device) – Device the models run on.max_samples (
int) – Maximum number of dataset indices scanned.checkbox_dict_in (
dict, optional) – Explicit{criterion: LongTensor (n_rows,)}rows to look for instead of the full2 ** ngrid; must contain a"class"key.batch_size (
int) – Batch size for the counterfactual explainer.
- Returns:
The composed comparison image from
make_image_grid.- Return type: