ML7: Responsible AI: fairness, explanations, privacy and security

Lesson 2 of 5 · reading 15–25 minutes; practice and project time is on the module page

Explaining models

🎯You'll be able to

Use permutation importance for an overview, "what if" changes for a single prediction, and explain both in plain words.

🏠The everyday picture

A cricket coach explains a loss two ways: overall ("we lost wickets in the middle overs") and for one moment ("that run-out happened because both batters ran for the same end"). Model explanations also come in overall and single-case forms.

📘What it really is

📝A worked example

Input: permutation importance on May for the kit's model, measured as the drop in PR-AUC, 5 repeats (reference figures, 2 November 2026).

Feature Drop in PR-AUC
address_quality 0.4234
dest_zone 0.0684
pickup_slot 0.0357
distance_km 0.0146
payment 0.0141
booked_hour −0.0103

Then a "what if" for one parcel (remote, evening pickup, cash on delivery, hub load 52, address score 0.31): probability 0.8533. With an address score of 0.6 it's 0.5077; with 0.9 it's 0.4285. With a local destination instead of remote it's 0.7611. The hub team can be told: "mostly the address; fixing it roughly halves the risk". A negative drop, like booked_hour's, means shuffling it made no real difference; the small change is noise.

🌍Where it's used

📝Case scenario

A model to spot pneumonia in chest X-rays scored well, but explanation maps showed it looked at a marker in the image's corner that differed between hospitals. One hospital had sicker patients, so the marker predicted the diagnosis. Removing the markers from the images, and testing on a new hospital, gave a more honest score.

🖱️Try it

Run sklearn.inspection.permutation_importance on May with scoring='average_precision', n_repeats=5 and random_state=0. Success: your top three features match the table, and you can explain the top one in one sentence for the hub team.

⚠️Common mistakes

🛠️For your project

The capstone design notes ask how a hub team member can see why a parcel was flagged.

✅Quick check

What does permutation importance measure?

Show the answer

How much the score drops when one feature's values are shuffled.

What's a "what if" explanation?

Show the answer

Changing one input of a single case and seeing how its prediction moves.

← PreviousFairness: measuring results by group
ProLearners Assist