Ce mondrian conditional

From Moffran/calibrated_explanations · View interactive version

Ce mondrian conditional is an AI agent skill from the GitHub repository Moffran/calibrated_explanations. Configure and validate Mondrian and conditional calibration for subgroup-aware uncertainty and fairness-sensitive workflows.

How to use this skill

Skill file

CE Mondrian Conditional

You are setting up Mondrian (conditional) calibration, which partitions

calibration data into subgroups so that each group receives its own

uncertainty estimate. This reveals group-specific prediction quality and is

the foundational technique for fairness-aware deployments in CE.

Research: Conditional Calibrated Explanations (xAI 2024)

Load references/mondrian_examples.md for full code examples (Options A/B/C,

fairness analysis, global vs conditional comparison).


Why Mondrian matters for fairness

Without conditional calibration, the CPS/Venn-Abers calibrator averages over

all calibration instances. A minority group with harder prediction patterns

may receive the same interval width as an easy majority group, hiding bias.

Mondrian splits calibration by a grouping key and fits a separate calibrator

per bin. Resulting intervals are:


Three options for specifying bins

via crepes.extras.MondrianCategorizer.


Calibration -> predict -> explain consistency rules

| Step | Bins argument |

|---|---|

| calibrate(...) | mc= (MondrianCategorizer or callable) OR bins= (integer array) |

| predict(x, ...) | nothing if mc was used at calibrate time OR bins=group_labels_test |

| predict_proba(x, ...) | same as above |

| explain_factual(x, ...) | same as above |

| explore_alternatives(x, ...) | same as above |

CRITICAL: always pass bins= at inference time whenever the explainer

was calibrated with inline Mondrian bins. Omitting it raises ValidationError;

passing bins= after global calibration raises ConfigurationError. When

mc= was used at calibration time, omit bins= at inference because the stored

categorizer derives labels automatically.

Recalibrating without bins= or mc= resets to global calibration. Use

calibrate(..., reuse_conditional=True) only when intentionally reusing a

stored categorizer on a new calibration set.


Minimum bin size warning

Mondrian calibration splits the calibration set by group. Too few samples

per bin leads to unreliable or very wide intervals.

Rule of thumb: aim for >= 30-50 calibration samples per bin.


Out of Scope

Evaluation Checklist

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.