Explainable Artificial Intelligence (VTR UGE 21), day 4 of 5

Reliability of Explanations

Prof. Dr. Utku Kose, Süleyman Demirel University

Reliability lab

Part A repeats the calibration error of ten cases step by step, with sliders for its numbers. Part B classifies four reliability diagrams by eye. Parts C and D repeat two further calculations of the lecture step by step: one prediction with two explanations, and two fairness measures. Part E computes two fairness measures by hand. Part F runs the deletion and insertion tests in the browser and measures the area under each curve, abbreviated AUC. Part G is a calibration game: Twelve questions answered with a confidence give a reliability diagram, an expected calibration error and a Brier score of one's own. In Parts A, C and D every intermediate value is rounded, and the next step continues with the rounded value, as in a calculation by hand.

Part A: The calibration error of ten cases, step by step

The worked example of the lecture: ten cases with their probabilities and labels, the same cases as in Python step 4. The probabilities are 0.05, 0.12, 0.35, 0.41, 0.62, 0.68, 0.81, 0.93, 0.97 and 0.22, and the labels 0, 0, 1, 0, 1, 1, 1, 1, 1 and 0. The controls choose the number of bins and whether every probability is squared, the change that keeps the order and worsens the calibration. The steps sort the cases into bins and compute the calibration error and the Brier score. The figure is the reliability diagram: one point per bin, sized by the number of its cases.

Back to the lecture: Can the probability be trusted?, where the text continues after the box of this part.

Part B: Calibration by eye

Each diagram plots the observed frequency against the mean predicted probability in bins, for one model. The dashed diagonal is perfect calibration. Decide what each model does and press Check the diagrams.

Back to the lecture: Can the probability be trusted?. The lecture continues there with Section 1 of the Colab notebook: Open it from the next orange box.

Part C: One prediction, two explanations

The worked example of the lecture: the model \(f(x_1, x_2)\)​\({} = \sigma(3(\sin(2 x_1) + x_2))\) gives the prediction 0.7685 at every point of the curve \(x_2 = 0.4 - \sin(2 x_1)\). The sliders place two points on this curve by their first coordinate. The steps compute the second coordinates, the prediction, the gradients, the explanations by gradient times input and their cosine similarity. The left figure shows the curve with the two points, and the right one draws the two explanations as arrows.

Back to the lecture: Can the explanation be manipulated?. The lecture continues there with Section 4 of the Colab notebook: Open it from the next orange box.

Part D: Two fairness measures, step by step

The worked example of the lecture: a model decides about 200 applicants of group A, of whom 100 would repay, and 150 of group B, of whom 60 would repay. The sliders set how many applicants of each kind the model approves. The steps compute the approval rate, the true positive rate and the false positive rate of both groups and the two differences of the lecture. The figure compares the three rates of the two groups.

Back to the lecture: Can the decision be trusted? Fairness and proxies, where the text continues after the box of this part.

Part E: Fairness measures by hand

A credit model was applied to 100 applicants of each group. Compute the two fairness measures of the lecture from the counts and press Check my values.

GroupApplicantsWould repayApproved, of those who would repay Approved, of those who would not
A10060455
B10050182

Back to the lecture: Can the decision be trusted? Fairness and proxies. The lecture continues there with Section 5 of the Colab notebook: Open it from the next orange box.

Part F: Deletion and insertion

A model of eight features explains twenty cases. Choose an explanation method and run the deletion and insertion tests: Features that support the prediction are removed first, or added first, and the probability of the predicted class is recorded. A faithful explanation makes the deletion curve fall fast and the insertion curve rise fast. Every run is compared with a random ranking, which any method must beat, including SHAP, short for Shapley additive explanations, and LIME, short for local interpretable model-agnostic explanations.

Scoreboard

RunExplanationNoiseDeletion AUCInsertion AUC FaithfulnessBeats random?

Back to the lecture: Does the explanation beat random?. The lecture continues there with Section 6 of the Colab notebook: Open it from the next orange box.

Part G: How sure are you? A calibration game

Twelve questions from geography, science and history, each with two answers. Choose an answer and say how sure you are, from 50 percent, a pure guess, to 100 percent, certain. A person is calibrated when the answers given with 70 percent confidence are right about 7 times in 10, as a model is calibrated when its probabilities match the observed frequencies. When all twelve questions are answered, Show my calibration draws the reliability diagram of the answers, with one point for every level of confidence, and computes the expected calibration error, abbreviated ECE, in the form of Guo and colleagues, with the confidence in the chosen answer and the share of right answers in each bin, \(\mathrm{ECE}\)​\({} = \sum_b (n_b / n)\, |\bar{y}_b - \bar{p}_b|\). The Brier score averages \((p - y)^2\) over the answers, with the confidence \(p\) and \(y = 1\) for a right answer and \(y = 0\) for a wrong one. Twelve answers are a small sample, so the result is a first impression.

Back to the lecture: Reliability in your field. The lecture continues there with Section 7 of the Colab notebook: Open it from the next orange box.