How to interpret a deep learning model's prediction results (Explainable AI/XAI)? What methods can achieve this?

陽一 和也
陽一 和也

Okay, no problem. Let's imagine and discuss this topic.


Hey, regarding the "black box" of deep learning models, how do we know why they make certain predictions? (Explainable AI/XAI)

Hello! I'm glad to discuss this topic with you. To be honest, the question you've raised is incredibly hot right now, and it's a hurdle all AI practitioners must confront.

Let's start with an analogy. Imagine a deep learning model as an incredibly skilled, yet somewhat "introverted" chef.

You give him a pile of ingredients (data), like tomatoes, eggs, flour, and scallions. With a flurry of activity, he whips up a perfect bowl of tomato and egg noodles (the prediction result). You taste it, and it's absolutely delicious! But when you ask him, "Chef, how did you make these noodles so tasty? Was it the quality of the tomatoes, or some special technique with the heat?"

The chef remains silent, simply pointing to a black box in the kitchen labeled "Trade Secret."

This "black box" is the core problem with deep learning models. We know they perform well, but we don't know the specific reasons behind their decisions. What if, one day, it identifies an apple as an orange? We wouldn't even know where to begin fixing it.

Explainable AI (XAI) is about finding a way to provide a "translator" for this "introverted chef," allowing us to understand his cooking philosophy.

Why do we absolutely need to open this "black box"?

  1. Trust: If an AI doctor diagnoses you with a certain illness, you'd surely want to know which indicators in your report led to that diagnosis, right? Only by understanding the reasons can we trust it.
  2. Correction and Optimization: If a model makes a mistake, for instance, an autonomous driving system misidentifying a roadside billboard as a pedestrian, we need to know which part went wrong to fix it and prevent future errors.
  3. Discovery of New Knowledge: Sometimes, models might uncover patterns that humans haven't even noticed. For example, in scientific research, they might discover a hidden correlation between a certain gene and a disease.
  4. Fairness and Ethics: For a model used to approve loans, we must ensure it's not rejecting you based on your gender, race, or address. Explainability helps us check for "bias" in the model.

So, what methods can we use to provide a "translator" for the chef?

There are many methods, but the underlying ideas are largely similar. Let's discuss a few mainstream and easy-to-understand ones.

1. "Highlight What's Most Important" (Saliency Maps / Attention)

This method is particularly intuitive, especially when dealing with images and text.

  • Scenario: You give the model an image with both a cat and a dog, asking it to identify the "cat."
  • How it explains: This method generates a "heatmap" that highlights the areas the model considers "most cat-like" in the original image using bright colors (e.g., red). You might see the cat's ears, whiskers, and eyes turn particularly red, while the dog next to it and the background remain mostly cool-toned.

(Image source: LIME paper)

In a nutshell: It's like being able to "see" where the model's attention is focused, understanding what it's "looking at" when making a decision.

2. "What if...?" - The Elimination Method (LIME & SHAP)

These are two very popular "hindsight" methods; they don't care how complex the model's internal structure is, only about the relationship between input and output.

LIME (Local Interpretable Model-agnostic Explanations)
  • Scenario: A model predicts an email is "spam."
  • How it explains: LIME's approach is straightforward and direct: "Make small changes and see how the result changes."
    • It will randomly obscure some words in the email, generating hundreds of "incomplete" versions.
    • Then, these incomplete emails are fed back into the model to see which versions are still classified as "spam" and which revert to "normal emails."
    • Through this process, it can discover, "Ah, it turns out that every time words like 'free,' 'win a prize,' or 'click link' are obscured, the model no longer considers it spam." Clearly, these words are the key decision criteria.

In a nutshell: LIME performs "attribution analysis" for a single prediction, telling you "this result was obtained because the input contained A, B, and C."

SHAP (SHapley Additive exPlanations)

SHAP can be seen as a "luxury upgrade" to LIME. It originates from game theory and has a more rigorous foundation.

  • Scenario: A model predicting house prices, with inputs like "area," "location," "floor," "age of property," etc.
  • How it explains: SHAP aims to determine how much each feature (e.g., "area") "contributed" to the final house price prediction.
    • It calculates the average impact of each feature across all possible "feature combinations." This is a bit complex, but you can think of it as fairly assessing each player's (feature's) contribution to the team's final score (the prediction result).
    • Finally, it provides a very clear breakdown, telling you: The base price is XX million, due to "large area," the price is +0.5 million; due to "good location," the price is +1 million; but due to "old property age," the price is -0.2 million... The final predicted price is XXX million.

In a nutshell: SHAP not only tells you which features are important but also quantifies whether each feature had a "positive" or "negative" effect, and by how much.

3. "Ask the Chef Directly" (Feature Importance)

Some models are inherently more "talkative" and less of a "black box." For example, decision tree models.

  • Scenario: You use a decision tree model to decide whether to approve a credit card for a user.
  • How it explains: The structure of a decision tree itself is a set of "IF-ELSE" rules. You can directly visualize it, like a flowchart.
    • Step 1: Check "Is annual income > 100,000?"
    • Yes -> Step 2: Check "Does the user own property?"
    • No -> Reject directly.
    • ...

In a nutshell: This method is like getting the chef's recipe directly, with every step clearly written out. However, the drawback is that only a few simpler models can do this; complex deep learning models cannot.


To summarize

  • Want to see what the model is "looking at" -> Use heatmaps/attention mechanisms.
  • Want to know "why this specific result" -> Use LIME for local attribution.
  • Want to know how much each factor contributed -> Use SHAP for quantitative analysis.
  • If the model itself is simple -> Directly examine its feature importance or internal structure.

Transforming AI from a "black box" into a "transparent box" that we can understand, trust, and improve is a crucial step in truly integrating AI technology into our lives. I hope this explanation gives you a general understanding of XAI!