Explainable Artificial Intelligence (VTR UGE 21), day 2 of 5
Prof. Dr. Utku Kose, Süleyman Demirel University
Parts A, B and C repeat three calculations of the lecture step by step, with sliders for their numbers: permutation importance on four tumours, the individual conditional expectation (ICE) curves, partial dependence and accumulated local effects of a product of two features, and a local surrogate in the manner of LIME, local interpretable model-agnostic explanations, on one feature. In these parts every intermediate value is rounded, and the next step continues with the rounded value, as in a calculation by hand. Part D computes Shapley values by hand for a model with three features, the values behind SHAP, short for Shapley additive explanations. Part E explains a case of a model with two features in three ways at once. Part F matches questions with the methods that answer them. Part G ranks the features of a house price model by shuffling its columns.
The worked example of the lecture: a rule calls a tumour benign when its worst area is below a threshold. Four test tumours, benign, malignant, benign and malignant, are decided first with their own areas and then after three shuffles of the areas. The first shuffle swaps the first two areas, the second exchanges the first and the second pair, and the third reverses the order. The sliders set the threshold and the four areas. The table in the figure marks every correct decision in green and every wrong one in red.
Back to the lecture: Which features matter? Permutation importance. The lecture continues there with Section 2 of the Colab notebook: Open it from the next orange box.
The worked example of the lecture: a model that multiplies its two features, \(f(x_1, x_2) = x_1 x_2\), and three cases whose first features are 1, 2 and 3. The sliders set the second feature of each case. The steps compute the ICE curves and the partial dependence of feature 1 at \(v = 1, 2, 3\), then the local effects of the two intervals, their accumulated curve and its centring. The figure draws the three ICE curves, their average and the curve of the accumulated local effects.
Back to the lecture: How does a feature act? Partial dependence and ICE. The lecture continues there with Section 3 of the Colab notebook: Open it from the next orange box.
The worked example of the lecture: a case with the feature value \(x = 2\), counted in standard deviations, and four samples at 1, 2, 3 and 6 with the answers 0.2, 0.4, 0.6 and 0.1 of the black box. The sliders set the kernel width \(h\) and the answer of the far sample at 6. The steps compute the weights, the weighted means, the slope of the surrogate and its fidelity \(R^2\). In the figure, the size of a dot shows the weight of its sample, the grey curve the kernel and the line the surrogate.
Back to the lecture: Why this case? LIME, where the text continues after the box of this part.
A model with three features, A, B and C, has the outputs below when only some features take the patient's values and the others take their average. Compute the Shapley value of each feature: the average, over the six orders in which the features can join, of the change of the output at the moment the feature joins.
| Features present | none | A | B | C | A, B | A, C | B, C | A, B, C |
|---|---|---|---|---|---|---|---|---|
| Model output | 0.30 | 0.50 | 0.40 | 0.30 | 0.70 | 0.55 | 0.45 | 0.80 |
Back to the lecture: Why this case? Shapley values and SHAP. The lecture continues there with Section 4 of the Colab notebook: Open it from the next orange box.
The heat map shows a model of two features, a and b, with an interaction: The effect of one feature depends on the value of the other. Click a point on the map to choose the case to explain. The panel then explains it in three ways: Exact Shapley values against the data mean, a local linear surrogate in the manner of LIME (local interpretable model-agnostic explanations) whose kernel width and seed you set, and the nearest counterfactual, drawn as a path to the decision boundary, the line on which the model output is 0.5.
The two Shapley values add up to the model output minus 0.5, the output at the data mean. A bar named LIME shows the slope of the surrogate times the distance of the case from the data mean, so that it can be compared with the Shapley value next to it. The LIME fidelity is the share of the variation of the model near the case that the surrogate reproduces, a number between 0 and 1. The formulas are on the lecture page, under the headings on LIME, on Shapley values and on choosing a method.
Back to the lecture: Choosing a method, where the text continues after the box of this part.
Each question below is answered best by one family of methods. Choose the method for every question and press Check the matches. In the list, a local attribution states how much each feature contributed to one prediction.
| Question | Method | Feedback |
|---|
Back to the lecture: Choosing a method, where the text continues after the box of this part.
A model predicts the price of ten houses, in thousands, from four features: the size in square metres, the distance to the city centre in kilometres, the number of rooms and the colour of the front door. Its error is the mean absolute error, the average distance between a predicted and a true price. A button shuffles one column of the table: The values of that feature move to other houses, the model predicts again, and the rise of the error is one drop \(D_{j,r}\) of permutation importance, with an error in place of an accuracy, so that a larger error means a larger drop. Shuffle each feature a few times, read the importance as the mean of its drops and their spread, and then rank the four features.
Back to the lecture: Explanations in your field. The lecture continues there with Section 7 of the Colab notebook: Open it from the next orange box.
Answer each question, rate your confidence and check the answer. Results stay in this browser.
Write a short answer to each question. The text is saved in this browser and is included when you export the learning log.