0% found this document useful (0 votes)
5 views44 pages

Module 7 XAI Complete Notes

The document discusses the importance of Explainable AI (XAI) in medical diagnosis and real estate sales prediction, emphasizing the need for transparency and trustworthiness in AI decisions. It outlines key goals of XAI, various techniques used for explanation, and the regulatory landscape mandating explainability. The document also presents a case study on a real estate firm's AI model, highlighting the challenges of black-box systems and the necessity for interpretable AI frameworks.

Uploaded by

swathysreeravi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views44 pages

Module 7 XAI Complete Notes

The document discusses the importance of Explainable AI (XAI) in medical diagnosis and real estate sales prediction, emphasizing the need for transparency and trustworthiness in AI decisions. It outlines key goals of XAI, various techniques used for explanation, and the regulatory landscape mandating explainability. The document also presents a case study on a real estate firm's AI model, highlighting the challenges of black-box systems and the necessity for interpretable AI frameworks.

Uploaded by

swathysreeravi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Module:7

Building Trustworthy Model


with Explainable AI
Medical diagnosis- Making AI Decisions Trustworthy for Physicians and
Patients – Sales predictions on the house sale.
• Medical Diagnosis : AI decisions must be trustworthy and transparent
to physicians and patients.
• Sales Prediction (House Sale) : XAI is used to explain data-driven
decisions in business and finance.
Medical Diagnosis: Making AI Decisions
Trustworthy for Physicians and Patients
AI models today assist in diagnosing diseases from:
• Medical images (CT, MRI, X-rays)
• Patient health records
• Genomic data
However, black-box models (like deep neural networks) lack
transparency ,physicians often cannot see why a diagnosis was made.
Thus, Explainable AI (XAI) is essential to bridge the trust gap between
AI systems and medical professionals.
Key Goals of XAI in Medical Diagnosis

Goal Description
Make AI reasoning visible ,show which features (e.g.,
Transparency
tumor size, glucose level) influenced a prediction
Ensure clinicians and patients can rely on AI results
Trustworthiness
with justified reasoning
Accountability Allow audit of AI decisions (why an error occurred)
Human–AI Collaboration Support doctors in decision-making, not replace them
XAI Techniques Used in Medical Diagnosis

XAI Method Explanation Type Example in Medicine


LIME (Local Interpretable Model- Explains why a chest X-ray was
Local, feature-level
Agnostic Explanations) classified as pneumonia
Shows contribution of blood
SHAP (SHapley Additive
Global + Local pressure, age, cholesterol to heart
exPlanations)
disease risk
Highlights tumor regions
Grad-CAM / Saliency Maps Visual
influencing CNN prediction
“If the glucose level were lower,
Counterfactual Explanations Hypothetical
diabetes risk would drop.”
Sales Prediction: XAI in House Price or House
Sale Forecasting
AI models predict property sale prices based on features such as:
• Location, area, and number of rooms
• Year built, neighborhood, proximity to amenities
• Market trends
These predictions affect financial and investment decisions, so
transparency and explainability are vital for stakeholder trust.
XAI Methods in Real Estate Prediction

XAI Technique Explanation Example Output


Contribution of each feature to
SHAP Values “Location ,Size ”
predicted price
Relationship between one feature Shows how price increases with
Partial Dependence Plot (PDP)
and output square footage
Reveals that removing “location”
Feature Permutation Tests model sensitivity
drastically reduces accuracy
Explains why this house was priced
LIME Local explanation for one property
higher than that one
EXPLAINABLE AI

Building Trustworthy AI
Explainable AI for House Sales Prediction

XAI Techniques Real Estate Trust & Fairness


A multinational real estate firm, EliteAbode, has deployed a
complex Gradient Boosted Tree model called "PricePulse" to
predict house sales prices. While the model boasts a high R-
squared value, a recent internal audit revealed that the model
consistently predicts lower valuations for properties in specific
zip codes despite high-quality renovations. Furthermore, bank
loan officers are hesitant to use the tool because the
"PricePulse" system provides no reasoning for its valuations.
You are appointed as the Lead AI Auditor to transition this
"Black Box" system into a Trustworthy AI framework.
high R-squared value indicates that the
model's independent variables (features
like square footage, number of rooms, and
age) are highly effective at explaining the
variation in the dependent variable (the
PRESENTATION ROADMAP

Agenda

01 The Challenge 02 Trustworthy AI Principles

03 XAI Techniques Overview 04 SHAP Deep Dive

05 Alternative XAI Methods 06 House Price Features

07 Implementation Pipeline 08 MLOps Best Practices

09 Case Study 10 Conclusion & Next Steps


THE PROBLEM

Why Explainability Matters in Real Estate


The Black-Box
Regulatory & Legal Requirements
Problem
Modern ML models achieve high accuracy but sacrifice interpretability. Fair Housing Act (FHA)

EU AI Act (High-Risk Systems)

$300K-$2M+ Fair Housing Act Algorithmic Accountability

The Accuracy vs. Interpretability Trade-off Stakeholder Trust Requirements

Buyers Sellers

Lenders Appraisers
FOUNDATION

Trustworthy AI: Six Pillars for Responsible ML


Explainabilit
y
SHAP values
show exactly how square footage adds $80K to a prediction.

Fairness

Audit for bias: ensure zip codes don't proxy for race or income.

Transparency
Publish
model cards detailing intended use and performance metrics.

Robustnes
s

Monitor for data drift and adversarial inputs in production.

Privacy
Use
differential privacy and federated learning where appropriate.

Accountability
Designate model owners
THE TOOLKIT

Explainable AI Techniques: A Comprehensive Landscape


Two Approaches to
XAI Method Comparison Matrix
Explainability
Model Computati
Method Scope Consistency
Support on
Intrinsic Post-Hoc
Local + Mathematically
SHAP Any High
Global Guaranteed

Local
LIME Any Medium Stochastic
Only

Permutation Global
Any Medium Deterministic
Pros: Fully transparent Pros: Model-agnostic Importance Only

Global
PDP Any High Deterministic
Only

Post-Hoc Method Categories


Global
ALE Plots Any Low Deterministic
Only
Feature Attribution Methods

Surrogate Global +
Any Medium Approximation
Models Local
Surrogate Models

SHAP for comprehensive analysis LIME for quick local


Visualization Methods explanations ALE plots for feature relationships with correlated data
CORE TECHNIQUE

SHAP: Game Theory-Powered Model Interpretation


The Foundation Python Implementation

Shapley values from cooperative game theory

Core Principle:

φ(i) = Σ [|S|!(n-|S|-1)!/n!] × [v(S∪{i}) - v(S)]

Key Properties

1 Efficiency

2 Symmetry

SHAP Visualization Types


3 Dummy
Summary Plot Waterfall Plot

4 Additivity

Force Plot Dependence Plot


COMPLEMENTARY TECHNIQUES

Alternative XAI Methods: LIME, PDP, and ALE


LIME PDP ALE

How It Works How It Works How It Works

Strengths Mathematical Formulation Key Advantage

PD_S(x_S) = E[f(x_S, X_C)] Handles correlated features correctly

Strengths Strengths
Limitations

Limitations Interpretation
DOMAIN KNOWLEDGE

House Price Prediction: Features and Dataset


Ames Housing Dataset Top Feature Importance (SHAP)

2,919 79 $180K

Feature Categories

Structural (20+) Quality (10+)

Feature Engineering Impact

Raw Features R² = 0.82


Location (15+) Temporal (5+)

Engineered Features R² = 0.91

Key: Total sqft × Quality interaction is often the #1 predictor


END-TO-END WORKFLOW

Implementation Pipeline: From Data to Explainable Predictions


Data
1
Preprocessing

Model
2
Training
Linear Regression Baseline (R²=0.75)

Random Forest Good (R²=0.88)

XGBoost Best (R²=0.92)

EBM (Glass-box) Interpretable (R²=0.89)

XAI
3
Integration

4 Deployment
PRODUCTION READINESS

MLOps Best Practices for Interpretable AI


Explanation Multi-Granularity
Caching Explanations

Global (Executives)

Local (Appraisers)

Reduces API latency by 80-90%


Debug (Data Scientists)

Explanation Drift
Monitoring
Explanation
Validation

Domain Knowledge Check

KL-Div > 0.1 Daily


Stability Testing

Explanation
Logging
Confidence Scores

Documentation Best
Practices
REAL-WORLD EXAMPLE

Case Study: Explaining a $500K House Prediction


Property Profile SHAP Waterfall Visualization

2,450 sqft 4

2015 3-car

$350,000 $500,000
+$150,000 above mean
Insights from Explanation

Validates Domain Knowledge


SHAP Feature Contributions

Neighborhood (Stone Brook) +$120K


Identifies Potential Issues
Gr Liv Area (2,450 sqft) +$80K

Kitchen Quality (Excellent) +$45K


Builds Stakeholder Trust
Garage (3-car) +$25K

Year Built (2015) -$30K Enables Model Improvement

Basement (Unfinished) -$20K


CONCLUSION

Building Trust, One Explanation at a Time


Key Takeaways Next Steps

1 Explainable AI transforms black-box predictions into trustworthy decisions Implement SHAP

SHAP provides mathematically grounded, consistent explanations Establish Monitoring


2

Conduct Bias Audits


3 Start with interpretable models when possible

Build Dashboards
4 Integrate XAI into MLOps pipeline from day one

5 Validate explanations against domain expertise


The Path Forward

6 Monitor explanation drift as rigorously as model performance


why

6 ∞

Explainable AI Trustworthy AI Real Estate AI


Explainable Artificial Intelligence (XAI) | In-Depth Scenario Study: Medical Diagnosis & House Sale Prediction

EXPLAINABLE ARTIFICIAL
INTELLIGENCE

XAI
Elaborate Scenario-Based Study Notes

SCENARIO 1 — Medical Diagnosis AI


Disease Risk Prediction | Cardiology | XAI for Clinical Decision Support

SCENARIO 2 — House Sale Price Prediction


Real Estate Valuation | Gradient Boosting | XAI for Finance & Property Markets

Techniques Covered: SHAP | LIME | Grad-CAM | PDP | Counterfactuals | Feature Importance | LORE |
Anchors

Page 1 of 24 | XAI Study Notes — Elaborated Edition


Explainable Artificial Intelligence (XAI) | In-Depth Scenario Study: Medical Diagnosis & House Sale Prediction

1. Foundations of Explainable AI (XAI)


Artificial Intelligence and Machine Learning models — especially deep neural networks, ensemble
methods like Random Forests and Gradient Boosting Machines, and black-box algorithms — often
produce highly accurate predictions without offering any human-readable explanation of how they
arrived at those predictions. This opacity is the central challenge that Explainable Artificial Intelligence
(XAI) addresses.

XAI is defined as a collection of methods, principles, and processes that allow AI systems to explain
their decisions, actions, and predictions in terms that are understandable and meaningful to human
users. The goal is not merely academic: in regulated industries such as healthcare, finance, law, and
public administration, the inability to explain an AI decision is not just a design flaw — it is a legal and
ethical violation.

1.1 The Black Box Problem


Traditional ML pipelines prioritize predictive accuracy above all else. A deep learning model with
millions of parameters may achieve 97% accuracy on a cancer detection task, but if a radiologist
cannot understand why the model flagged an image, the model cannot be trusted or safely deployed.
This is the black-box problem: high internal complexity creates a disconnect between model behavior
and human comprehension.

Key Insight: The Accuracy–Interpretability Trade-off


Simple models (Linear Regression, Decision Trees): Low accuracy, High interpretability

Complex models (Deep Learning, Gradient Boosting): High accuracy, Low interpretability

XAI bridges this gap — applying post-hoc or intrinsic explanation methods to complex models

The goal: retain the accuracy of complex models while recovering the interpretability of simple ones

1.2 Taxonomy of XAI Methods


XAI methods are classified along three orthogonal dimensions:

Dimension Category A Category B

Intrinsic — interpretable by design Post-hoc — applied after training (SHAP,


Timing
(Decision Tree, Linear Regression) LIME, Grad-CAM)

Local — explains a single prediction Global — explains the model's overall


Scope
for one data point behavior across all data

Model-specific — designed for one


Model Model-agnostic — works with any model
model type (e.g., Grad-CAM for
Dependency (SHAP, LIME, PDP, Counterfactuals)
CNNs)

Page 2 of 24 | XAI Study Notes — Elaborated Edition


Explainable Artificial Intelligence (XAI) | In-Depth Scenario Study: Medical Diagnosis & House Sale Prediction

1.3 Core XAI Properties


Property Definition Why It Matters

The model's internal logic is open to Regulators, auditors, and experts can verify
Transparency
inspection model behavior

Outputs can be understood by the Non-technical stakeholders (patients,


Interpretability
target audience buyers) can act on the explanation

Model does not encode unjust bias Prevents discrimination; required by law in
Fairness
across groups many sectors

Decisions can be traced and Enables correction, auditing, and legal


Accountability
attributed responsibility

Explanation accurately reflects the Prevents misleading or incorrect


Fidelity
model's true reasoning explanations

Explanation covers all relevant Ensures nothing important is hidden from the
Completeness
influencing factors user

1.4 Regulatory Landscape


XAI is no longer optional — it is mandated by law in multiple jurisdictions. The following regulations
directly require explainability in AI systems:
• EU AI Act (2024): High-risk AI systems (medical, financial, employment) must provide
explanations for decisions and be auditable by national authorities.
• GDPR Article 22 (EU): Individuals subject to automated decisions have the right to
meaningful information about the logic involved.
• FDA AI/ML Guidance (USA): AI-based medical devices must demonstrate transparency and
predictability; post-market monitoring is required.
• Fair Credit Reporting Act (USA): Lenders must provide specific reasons for adverse
credit/loan decisions — mandating explainability in financial AI.
• RBI Digital Lending Guidelines (India): Algorithms used for credit decisions must be
explainable and auditable.

Page 3 of 24 | XAI Study Notes — Elaborated Edition


Explainable Artificial Intelligence (XAI) | In-Depth Scenario Study: Medical Diagnosis & House Sale Prediction

SCENARIO 1 — MEDICAL DIAGNOSIS AI

2. Scenario 1: Cardiovascular Disease Risk Prediction

2.1 Background & Clinical Context


Cardiovascular disease (CVD) is the leading cause of death globally, accounting for approximately
17.9 million deaths per year according to the World Health Organization. Early risk detection is critical
for preventive intervention. Machine Learning models trained on patient health records can identify
high-risk individuals earlier and more accurately than traditional risk scoring tools (e.g., Framingham
Risk Score).

A hospital system deploys a Gradient Boosting Classifier (XGBoost) to assess patient cardiovascular
risk. The model is trained on 50,000 patient records and achieves 91% accuracy on the test set.
However, clinicians raise concerns: the model is a black box. A physician cannot ethically act on a
risk label of 'HIGH' without understanding the contributing factors. XAI is applied to make each
prediction clinically interpretable.

2.2 System Architecture


The XAI-enabled medical diagnosis system operates as a multi-layer pipeline:

(1) (2) (3) (4) (5) (6)

SHAP / LIME / Clinical Physician +


Data Collection Feature XGBoost Model
Grad-CAM Explanation Patient
& Cleaning Engineering Training
Layer Report Decision

Each stage is described below:


• Stage 1: Patient EHR data (Electronic Health Records) is collected, cleaned, and
normalized. Missing values are imputed using median imputation for continuous variables
and mode for categorical.
• Stage 2: Feature engineering transforms raw data — e.g., computing BMI from height and
weight, flagging borderline blood pressure, encoding smoking history as ordinal.
• Stage 3: XGBoost model produces a probability score: P(CVD = HIGH | features). A
threshold of 0.50 is applied; scores above this classify the patient as HIGH RISK.
• Stage 4: The XAI layer runs SHAP to explain the prediction. For imaging data (ECG, X-
rays), Grad-CAM highlights relevant image regions.
• Stage 5: A structured clinical report is generated — feature contributions, risk score,
comparison to population baseline, and recommendations.
• Stage 6: The physician reviews the explanation and makes the final clinical decision. The AI
recommends; the human decides.

Page 4 of 24 | XAI Study Notes — Elaborated Edition


Explainable Artificial Intelligence (XAI) | In-Depth Scenario Study: Medical Diagnosis & House Sale Prediction

2.3 Sample Patient Dataset


The model is trained on patient records containing 8 clinical features. Below is a representative
sample of 8 patients from the test set, showing actual labels alongside model predictions:

BP Chol. Glucose Actual AI


ID Age BMI Smoker Exercise
(mmHg) (mg/dL) (mg/dL) Risk Score

P001 62 150/90 240 105 28.5 Yes Low HIGH 0.87

P002 45 120/80 190 90 23.1 No High LOW 0.12

P003 58 145/88 230 115 31.2 Yes Low HIGH 0.82

P004 38 118/75 175 85 21.9 No High LOW 0.08

P005 70 160/95 260 130 33.8 Yes None HIGH 0.95

P006 52 130/82 210 98 25.6 No Moderate HIGH 0.61

P007 49 125/80 195 92 24.8 No High LOW 0.22

P008 67 155/92 248 122 30.5 Yes Low HIGH 0.91

Note: AI Score = P(HIGH RISK) output from XGBoost. Scores >= 0.50 classify as HIGH. P006 (score
0.61) is a borderline case — XAI explanations are especially critical for such patients.

2.4 XAI Technique 1 — SHAP (SHapley Additive exPlanations)


2.4.1 Theoretical Foundation
SHAP is rooted in cooperative game theory, specifically Shapley values introduced by Lloyd Shapley
in 1953. In game theory, the Shapley value represents a fair way to distribute the total payoff of a
cooperative game among all players. SHAP adapts this: each feature is a 'player', each prediction is
the 'game', and the Shapley value of a feature is its fair contribution to moving the prediction away
from the baseline (mean prediction across training data).

Name Formula / Expression Explanation

phi_i(f,x) = SUM_{S in F\{i}} [ phi_i = contribution of feature


Shapley Value |S|!(|F|-|S|-1)!/|F|! ] * [f(S u i; S = feature subset; F = all
{i}) - f(S)] features; f = model output

f(x) = phi_0 + phi_1 + phi_2 + ... phi_0 = baseline (mean


SHAP Prediction + phi_n prediction); sum of all SHAP
values = final model output

SUM_{i=1}^{n} phi_i = f(x) - The sum of all SHAP values


SHAP Fidelity E[f(x)] exactly equals the difference

Page 5 of 24 | XAI Study Notes — Elaborated Edition


Explainable Artificial Intelligence (XAI) | In-Depth Scenario Study: Medical Diagnosis & House Sale Prediction

between prediction and


baseline

E[f(x)] = (1/N) * SUM_{j=1}^{N} Baseline = average model


Expected Value f(x_j) output over all N training
samples

2.4.2 SHAP Values for Patient P001 — Detailed Breakdown


Patient P001 (Age 62, BP 150/90, Cholesterol 240, Smoker: Yes) received a risk score of 0.87. The
baseline (population average) risk is 0.35. SHAP explains how each feature contributed to moving
the prediction from 0.35 to 0.87:

Patient Population SHAP Cumulative


Feature Clinical Interpretation
Value Mean Value Score

Baseline Average population risk


— — 0.000 0.350
(E[f]) score

Age 62 is significantly above


Age 62 yrs 48 yrs +0.148 0.498 the 48-yr mean; major risk
driver

Blood Stage 2 hypertension —


150/90 122/80 +0.137 0.635
Pressure 28mm above avg systolic

240 Borderline-high; 45 mg/dL


Cholesterol 195 mg/dL +0.098 0.733
mg/dL above population average

Smoking adds significant


Smoker Yes 22% yes +0.072 0.805
independent risk

Exercise Sedentary lifestyle


Low Moderate +0.044 0.849
Level compounds metabolic risk

Slightly overweight;
BMI 28.5 26.2 +0.031 0.880 moderate additive
contribution

105 Glucose within normal range


Glucose 95 mg/dL -0.010 0.870
mg/dL — slight protective effect

Clinical Summary: The model's prediction of 0.87 (HIGH RISK) for P001 is driven almost entirely by
the classic cardiovascular risk triad: hypertension (+0.137), elevated cholesterol (+0.098), and old
age (+0.148). Combined with smoking and sedentary lifestyle, these features collectively push the
risk score 0.52 above the population baseline. This explanation maps perfectly onto established
cardiology risk frameworks (Framingham, ACC/AHA Guidelines), validating the AI model's clinical
reasoning.

2.4.3 SHAP for Borderline Case P006

Page 6 of 24 | XAI Study Notes — Elaborated Edition


Explainable Artificial Intelligence (XAI) | In-Depth Scenario Study: Medical Diagnosis & House Sale Prediction

Borderline cases (score 0.50–0.70) are the most clinically important for XAI. P006 scored 0.61 —
barely above the HIGH RISK threshold. The SHAP explanation reveals:
• Primary drivers: BP 130/82 (+0.08) and Cholesterol 210 (+0.06) — both mildly elevated
• Neutral factors: Age 52 contributes +0.04, BMI 25.6 is nearly neutral at +0.01
• Protective factor: Being a non-smoker contributes -0.05 (reduces risk)
• Moderate exercise provides -0.03 protective contribution
Conclusion: P006 is borderline HIGH RISK due to mild but consistent elevation across multiple
risk factors. The physician can use this to counsel targeted lifestyle intervention rather than
immediate medication.

2.5 XAI Technique 2 — LIME (Local Interpretable Model-agnostic


Explanations)
2.5.1 How LIME Works
LIME generates a locally faithful linear explanation around a specific prediction. It works by perturbing
the input (creating synthetic neighbors), observing how the model's prediction changes, and fitting a
weighted linear regression in that local neighborhood. The coefficients of this linear model are the
explanation.

Name Formula / Expression Explanation

argmin_{g in G} L(f, g, pi_x) + f=complex model; g=simple


Omega(g) interpretable model;
LIME Objective
pi_x=proximity kernel;
Omega=complexity penalty

pi_x(z) = exp(-D(x,z)^2 / sigma^2) Measures similarity between


original x and perturbed
Proximity Kernel
sample z; sigma controls
neighborhood width

L(f,g,pi_x) = SUM_z pi_x(z) * Weighted squared error


[f(z) - g(z)]^2 between complex and simple
Local Loss
model; minimized in the local
neighborhood

g(z) = w_1*z_1 + w_2*z_2 + ... + Linear model with k most


w_k*z_k important features; weights
Explanation
w_i are the LIME explanation
values

2.5.2 LIME Output for Patient P003


For P003 (Age 58, pre-diabetic, smoker, HIGH RISK score 0.82), LIME generated the following local
linear model by creating 500 perturbed synthetic patient records:

Page 7 of 24 | XAI Study Notes — Elaborated Edition


Explainable Artificial Intelligence (XAI) | In-Depth Scenario Study: Medical Diagnosis & House Sale Prediction

LIME % of Confidence
Feature Direction
Weight Explanation Interval

Blood Pressure >


+0.34 Increases risk 28% [+0.29, +0.39]
140

Glucose > 110 +0.27 Increases risk 22% [+0.22, +0.32]

Age > 55 +0.21 Increases risk 17% [+0.17, +0.25]

Smoker = Yes +0.18 Increases risk 15% [+0.14, +0.22]

Moderate
Cholesterol > 200 +0.13 11% [+0.09, +0.17]
increase

Moderate
Exercise = Low +0.09 7% [+0.06, +0.12]
increase

The LIME explanation for P003 indicates that hypertension (BP > 140) is the single biggest local
driver at 28%, followed closely by elevated glucose (22%) which signals pre-diabetic metabolic
dysfunction. Note that LIME uses binary feature indicators (thresholds) rather than raw values,
making it particularly easy for clinicians to communicate: 'Your blood pressure above 140 is the main
reason you scored HIGH RISK.'

2.6 XAI Technique 3 — Grad-CAM for Medical Imaging


2.6.1 Application in Radiology AI
When the AI analyzes medical images — chest X-rays, ECG waveforms, MRI brain scans, retinal
fundus images, or dermatology slides — saliency maps are the primary XAI tool. Gradient-weighted
Class Activation Mapping (Grad-CAM) is the most widely used technique.

Name Formula / Expression Explanation

alpha_k^c = (1/Z) * SUM_i SUM_j (d alpha = weight of feature map


y^c / d A^k_{ij}) k for class c; Z = normalizing
Neuron Importance
factor; y^c = class score; A =
activation map

L^c_{Grad-CAM} = ReLU( SUM_k ReLU removes negative


alpha_k^c * A^k ) influences; final heatmap
Grad-CAM Heatmap
highlights regions that
positively activated class c

Importance(i,j) = L^c_{Grad- Normalized pixel-level


CAM}(i,j) / max(L^c) importance; values near 1.0 =
Pixel Contribution
highest contribution to the
prediction

Grad-CAM Clinical Example: Chest X-Ray Pneumonia Detection

Page 8 of 24 | XAI Study Notes — Elaborated Edition


Explainable Artificial Intelligence (XAI) | In-Depth Scenario Study: Medical Diagnosis & House Sale Prediction

Input: Chest X-ray image (P009, 55-year-old, fever, cough for 5 days)

Model Output: Pneumonia Positive — Confidence: 93.2%

Grad-CAM Heatmap: Bright red overlay concentrated in lower-left lobe (consolidation zone)

Radiologist Verification: Confirmed right lower lobe infiltrate matching Grad-CAM highlight

Clinical Value: Physician can verify the model focused on the correct anatomical region — not a
spurious artifact

Safety Gate: If Grad-CAM highlights regions inconsistent with the diagnosis, the physician can
override

2.7 XAI Technique 4 — Anchors


Anchors are rule-based local explanations that identify sufficient conditions for a prediction. Unlike
SHAP (which gives continuous weights), Anchors produce IF-THEN rules with a precision and
coverage score.

Anchor Explanation for P005 (Score 0.95 — Very HIGH RISK)


Anchor Rule: IF Age > 65 AND Blood Pressure > 155 AND Smoker = Yes

THEN Cardiovascular Risk = HIGH

Precision: 0.98 (98% of patients matching this rule are HIGH RISK)

Coverage: 0.12 (12% of all patients fall within this anchor rule)

Interpretation: This rule alone is sufficient to classify as HIGH. The other features (cholesterol,
glucose, BMI)

do not need to be checked once these three anchor conditions are met.

Clinical Use: Enables rapid triage — patients matching the anchor rule can be fast-tracked to
cardiology.

2.8 Evaluation Metrics for Medical AI + XAI


Value for
Metric Formula Clinical Significance
Model

Accuracy (TP+TN)/(TP+TN+FP+FN) 91.2% Correct risk assignments

Sensitivity Catches 94.6% of actual CVD


TP / (TP + FN) 94.6%
(Recall) cases

88.1% of healthy patients


Specificity TN / (TN + FP) 88.1%
correctly cleared

Page 9 of 24 | XAI Study Notes — Elaborated Edition


Explainable Artificial Intelligence (XAI) | In-Depth Scenario Study: Medical Diagnosis & House Sale Prediction

Near-perfect discrimination
AUC-ROC Area under ROC curve 0.963
between risk classes

SHAP 0.031 avg Similar patients get similar SHAP


|phi_i(x) - phi_i(x')| / |x - x'|
Consistency delta explanations

Corr(SHAP_sum, f(x) - SHAP values accurately reflect


Faithfulness r = 0.997
baseline) model reasoning

LIME Coverage N_explained / N_total 100% Every prediction can be explained

2.9 Clinical Explanation Report — Sample Output


The following is the structured XAI report generated for Patient P001, designed to be read by both
the attending physician and (in simplified form) the patient:

CLINICAL XAI REPORT — Patient P001 — Cardiovascular Risk Assessment


Patient ID: P001 | Age: 62 | Date: April 2026 | Attending: Dr. R. Sharma, Cardiology

AI RISK SCORE: 0.87 (HIGH RISK) | Threshold: 0.50 | Model: XGBoost v3.1 | Accuracy:
91.2%

TOP CONTRIBUTING FACTORS (SHAP Analysis):

[+0.148] Age 62 yrs -- 15 years above the mean population age in this dataset

[+0.137] Blood Pressure 150/90 -- Stage 2 Hypertension (JNC-8 criteria)

[+0.098] Cholesterol 240 mg/dL -- Borderline-high; 45 mg/dL above average

[+0.072] Smoker (active) -- Significant independent CVD risk factor

[+0.044] Low exercise -- Sedentary lifestyle amplifies metabolic risk

[-0.010] Glucose 105 mg/dL -- Normal range; mild protective contribution

PHYSICIAN RECOMMENDATION: Initiate statin therapy discussion; BP management protocol;


smoking cessation referral.

NOTE: This AI output is a clinical decision support tool. Final diagnosis and treatment decisions rest
with the physician.

2.10 Challenges & Ethical Considerations in Medical XAI

Page 10 of 24 | XAI Study Notes — Elaborated Edition


Explainable Artificial Intelligence (XAI) | In-Depth Scenario Study: Medical Diagnosis & House Sale Prediction

• Demographic Bias: If the training data under-represents certain ethnic groups, SHAP values
for those groups may be unreliable. Regular bias audits are mandatory.
• Over-reliance Risk: Physicians may defer entirely to AI explanations, reducing independent
clinical judgment. XAI must be positioned as support, not authority.
• Explanation Consistency: LIME may produce slightly different explanations each run (due to
random sampling). Stability testing across multiple runs is recommended.
• Data Privacy: Generating SHAP explanations requires access to training data distributions.
In federated learning settings, this must be handled without exposing individual records.
• Regulatory Gap: Current FDA guidance on AI medical devices does not yet fully specify how
XAI explanations should be validated — creating uncertainty for developers.

Page 11 of 24 | XAI Study Notes — Elaborated Edition


Explainable Artificial Intelligence (XAI) | In-Depth Scenario Study: Medical Diagnosis & House Sale Prediction

SCENARIO 2 — HOUSE SALE PRICE PREDICTION

3. Scenario 2: Real Estate Price Prediction

3.1 Background & Business Context


Real estate markets involve some of the largest financial decisions individuals make in their lifetimes.
A mismatch between perceived and actual property value can result in significant financial loss for
buyers, sellers, or lenders. Traditional valuation methods (comparative market analysis, appraisals)
are time-consuming, expensive, and subject to human bias.

A PropTech company deploys a Gradient Boosting Regressor (LightGBM) trained on 200,000


historical property transactions. The model predicts sale price in Indian Rupees (Lakhs). While the
model achieves a Mean Absolute Error (MAE) of ₹2.8L, stakeholders — buyers, sellers, banks
approving home loans, and government regulatory bodies — demand explanations: Why is this
property valued at ₹95L? Is the AI being fair? What can be done to increase the price?

3.2 System Architecture


(1) (2) (3) (4) (5) (6)

Data LightGBM SHAP + PDP + Price


Property Data Stakeholder
Preprocessing Regression Counterfactual Explanation
Ingestion Decision
& Encoding Model Layer Dashboard

3.3 Extended Sample Property Dataset


The following dataset contains 10 property records used to train and validate the model. Eight input
features are used:

Area Age Location Near Last Floor Price


ID Bedrooms Parking
(sqft) (yrs) Grade School Renov. No. (L)

A
H001 1800 4 5 Yes Yes 2023 6 95
(Premium)

H002 1200 3 15 B (Good) No Yes None 3 62

A
H003 2200 5 2 Yes Yes 2024 8 128
(Premium)

C
H004 950 2 25 No No None 1 38
(Average)

Page 12 of 24 | XAI Study Notes — Elaborated Edition


Explainable Artificial Intelligence (XAI) | In-Depth Scenario Study: Medical Diagnosis & House Sale Prediction

H005 1600 3 8 B (Good) Yes Yes 2020 4 78

A
H006 3000 6 1 Yes Yes New 10 182
(Premium)

H007 1400 3 12 B (Good) Yes No 2019 2 68

A
H008 2600 5 3 Yes Yes 2022 7 155
(Premium)

C
H009 1100 2 20 No Yes 2018 3 44
(Average)

H010 1750 4 6 B (Good) Yes Yes 2021 5 88

3.4 XAI Technique 1 — SHAP for Regression


3.4.1 Adapted SHAP for Continuous Outputs
In regression tasks, SHAP values represent the monetary contribution (in ₹ Lakhs) of each feature to
the predicted price, relative to the average predicted price across all properties in the training dataset.
The baseline for this model is ₹79.4L (mean predicted price).

Name Formula / Expression Explanation

f(x) = E[f(x)] + SUM_{i=1}^{p} f(x)=predicted price;


phi_i(x) E[f(x)]=mean price (baseline);
Regression SHAP
phi_i=price contribution of
feature i

phi_{i,j}(f,x) = [f_{S u {i,j}} - Measures interaction effect


f_{S u {i}} - f_{S u {j}} + f_S] / between features i and j —
SHAP Interaction 2 e.g., how Area x Location
interact

O(TL2^M) time complexity T=trees; L=leaves; M=max


depth; TreeSHAP is exact and
TreeSHAP (Fast)
computationally efficient for
GBMs

3.4.2 SHAP Decomposition for H001 (₹95L)


Starting from the baseline of ₹79.4L, each feature adds or subtracts value:

SHAP % Running
Feature Value Explanation
(L) Weight Total

Average predicted price across all


Baseline E[f] — — — ₹79.4L
200K training records

Page 13 of 24 | XAI Study Notes — Elaborated Edition


Explainable Artificial Intelligence (XAI) | In-Depth Scenario Study: Medical Diagnosis & House Sale Prediction

Grade A areas command highest


Location A
+18.5 26.7% ₹97.9L premiums; proximity to commerce,
Grade (Premium)
safety, amenities

1800 sqft is above 1520 avg; each


Area (sqft) 1800 sqft +15.2 21.9% ₹113.1L 100 sqft adds approx ₹3.8L in Grade
A

2023 renovation signals modern


Renovation
2023 +11.0 15.9% ₹124.1L finishes; adds significant market
Year
appeal

School proximity is a top search filter


Near School Yes +9.3 13.4% ₹133.4L for family buyers; strong demand
driver

4 BHK is above market median (3


Bedrooms 4 BHK +7.4 10.7% ₹140.8L BHK); premium for larger family
configuration

Mid-high floors valued for views and


Floor No. 6th Floor +2.5 3.6% ₹143.3L reduced noise; 6th is optimal in this
market

Dedicated parking adds marginal but


Parking Yes +1.8 2.6% ₹145.1L
consistent value

5-year-old building has some


House Age 5 years -5.4 -7.8% ₹139.7L depreciation; though partially offset
by the 2023 renovation

Rounding / Model calibration offset (interaction


— -44.7 — ₹95.0L
Other effects not listed individually)

The SHAP waterfall reveals that location grade alone accounts for ₹18.5L of the ₹15.6L premium
above baseline (note: interaction effects cause the individual contributions to not sum linearly in a
simple way, but their total correctly accounts for the full price). This enables a clear, defensible
valuation narrative for bank loan officers.

3.5 XAI Technique 2 — Partial Dependence Plots (PDP)


3.5.1 Theory & Formula
While SHAP explains individual predictions, Partial Dependence Plots (PDPs) explain the model's
global behavior — how the predicted price changes as a single feature varies, while all other features
are held at their average values. PDPs are essential for understanding market-wide trends.

Name Formula / Expression Explanation

PDP(x_s) = (1/n) * SUM_{i=1}^{n} x_s = feature of interest


PDP Definition f(x_s, x_C^{(i)}) (varied); x_C = all other

Page 14 of 24 | XAI Study Notes — Elaborated Edition


Explainable Artificial Intelligence (XAI) | In-Depth Scenario Study: Medical Diagnosis & House Sale Prediction

features (averaged over n


training records); f = model

dPDP/dx_s = [PDP(x_s + h) - Numerical derivative — rate of


PDP Slope (Rate) PDP(x_s - h)] / (2h) price change per unit increase
in feature x_s

ME_i = E[dPDP/dx_s] over all Average price sensitivity to


Marginal Effect training values feature i across the entire
data distribution

ICE_i(x_s) = f(x_s, x_C^{(i)}) Individual Conditional


Expectation — one line per
ICE Plot
property showing
heterogeneous effects

3.5.2 PDP Findings for Key Features


Feature PDP Trend Description Business Insight

Buyers pay proportionally more for medium


Price rises steeply from 600-2000 sqft
homes. Very large homes (3500+ sqft) have
Area (sqft) (+₹45L total). Rate slows above 2000
reduced price-per-sqft due to limited buyer
sqft. Flattens above 3200 sqft.
pool.

Price drops ₹2.1L per year for first 10 Sellers should prioritize renovation if home is
House Age years. Decline slows for 10-20 years. 8-15 years old — maximum depreciation
(yrs) Stabilizes (or slightly rises for vintage zone. Vintage homes (25+ yrs) with original
homes) beyond 25 years. character may hold or appreciate.

Location grade creates a non-linear premium


Grade C baseline = ₹42L avg. Grade
Location — moving C to B is worth ₹26L, but B to A is
B = ₹68L (+₹26L premium). Grade A
Grade worth ₹34L more. Confirms location as
= ₹102L (+₹60L premium over C).
dominant value driver.

No renovation = ₹0 premium. 5-10yr Recent renovations provide strong ROI. A


Renovation old renovation = +₹6L. 1-3yr ₹4-6L renovation costing the seller in 2024
Year renovation = +₹12L. Brand new = can add ₹10-12L to sale price — strong 2x
+₹15L. return.

Ground floor (0) = lowest. Rises to


Mid-level floors command optimal pricing.
Floor peak at 6th-8th floor (+₹4L). Slight
Very high floors require confirmed lift
Number decline above 10th floor without
infrastructure to maintain premium.
elevator premium.

3.6 XAI Technique 3 — Counterfactual Explanations


3.6.1 Generating Actionable Insights
Counterfactual explanations answer the seller's most important question: 'What would I need to
change about this property to reach my target price?' Unlike SHAP (which explains the current
decision), counterfactuals describe a realistic alternative scenario.

Page 15 of 24 | XAI Study Notes — Elaborated Edition


Explainable Artificial Intelligence (XAI) | In-Depth Scenario Study: Medical Diagnosis & House Sale Prediction

Name Formula / Expression Explanation

argmin_x' lambda * |f(x') - y'| + Find x' (modified property)


d(x, x') closest to original x that
Counterfactual
achieves target price y';
Objective
lambda balances price vs.
change effort

d(x, x') = SUM_j (|x_j - x'_j| / Normalized Manhattan


sigma_j) distance; sigma_j = feature
Feature Distance
standard deviation; penalizes
large unrealistic changes

minimize ||x - x'||^2 subject to Wachter's 2017 approach:


f(x') = y' minimize feature change while
Wachter Method
achieving exact target
outcome

3.6.2 Counterfactual Analysis for H002 (Current: ₹62L)


Seller of H002 wants to reach ₹80L before selling. The counterfactual engine suggests the following
feasible changes ranked by cost-effectiveness:

Estimated Price New Predicted


Scenario Change Required ROI
Cost Impact Price

CF-1: Full interior renovation


₹4.5L +₹12.0L ₹74.0L 2.7x
Renovation (2024)

CF-2: Reno + Renovation + near-school


₹4.5L +₹18.5L ₹80.5L 4.1x
School listing optimization

CF-3: Expand Add 200 sqft (balcony


₹6.0L +₹9.0L ₹71.0L 1.5x
Area conversion)

CF-4: Grade Not feasible — location


N/A N/A N/A N/A
Upgrade grade is fixed

Result: CF-2 is the optimal strategy — a ₹4.5L renovation investment plus optimizing the listing to
highlight school proximity achieves the ₹80L target with a 4.1x ROI. This is a concrete, actionable
XAI output that directly guides the seller's decision-making.

3.7 XAI Technique 4 — Global Feature Importance


3.7.1 Permutation Importance
Global feature importance tells us which features matter most across all 200,000 training properties
— not just for one specific house. It is computed using permutation importance: randomly shuffling
one feature at a time and measuring how much the model's MAE increases.

Page 16 of 24 | XAI Study Notes — Elaborated Edition


Explainable Artificial Intelligence (XAI) | In-Depth Scenario Study: Medical Diagnosis & House Sale Prediction

Name Formula / Expression Explanation

PI_j = [ L(f, D_{perm,j}) - L(f, L = MAE loss; D_perm_j =


Permutation D) ] / L(f, D) dataset with feature j
Importance randomly shuffled; measures
% accuracy loss

I_j = PI_j / SUM_k PI_k Normalized to sum to 1.0;


Normalized
allows percentage-based
Importance
ranking of all features

SHAP_GI_j = E_x[ |phi_j(x)| ] Mean absolute SHAP value


SHAP Global across all training instances;
Importance model-consistent global
importance

3.7.2 Feature Importance Results


Permutation SHAP Global (avg % of Total
Rank Feature Actionable
PI |phi|) Value

Location
1 0.421 ₹22.4L 31% No (Fixed)
Grade

2 Area (sqft) 0.318 ₹17.1L 23% Partial

Renovation
3 0.241 ₹13.8L 17% Yes (High ROI)
Year

4 Near School 0.178 ₹9.5L 12% Partial

5 Bedrooms 0.131 ₹7.2L 9% Partial

6 Floor Number 0.088 ₹4.1L 5% No

Partial
7 House Age 0.075 ₹3.9L 4%
(Renovation)

8 Parking 0.048 ₹2.3L 3% Partial

3.8 XAI Technique 5 — LORE (Local Rule-based Explanations)


LORE (Local Rule-based Explanations) generates both an explanation rule and a set of
counterfactual rules for a prediction. It uses a decision tree fitted on a neighborhood of synthetic
records around the target property.

LORE Output for H004 (950 sqft, Grade C, ₹38L)


EXPLANATION RULE (why ₹38L was predicted):

IF Area < 1000 AND Location_Grade = C AND No_Renovation = True

Page 17 of 24 | XAI Study Notes — Elaborated Edition


Explainable Artificial Intelligence (XAI) | In-Depth Scenario Study: Medical Diagnosis & House Sale Prediction

THEN Predicted_Price = LOW (₹35L – ₹45L range)

Rule Precision: 0.94 | Rule Coverage: 8.2% of all properties

COUNTERFACTUAL RULES (how to increase price):

CF-A: IF Location_Grade = B THEN Predicted_Price += ₹24L (price would reach ~₹62L)

CF-B: IF Area >= 1200 THEN Predicted_Price += ₹14L (price would reach ~₹52L)

CF-C: IF Renovation_Year >= 2022 THEN Predicted_Price += ₹9L (price would reach ~₹47L)

Most feasible action: CF-C — Renovate property. Investment ~₹3L, gain ~₹9L (3x ROI).

3.9 Model Performance Metrics


Model
Metric Formula Interpretation
Value

MAE (1/n) SUM |y_i - y^_i| ₹2.8L Average error of ₹2.8L on ₹79.4L avg price

SQRT[(1/n) SUM (y_i - Penalizes large errors; still within 5% of avg


RMSE ₹4.1L
y^_i)^2] price

(1/n) SUM |y_i - y^_i| / y_i Mean absolute % error — excellent for
MAPE 3.52%
* 100 valuation model

R-squared 1 - SS_res / SS_tot 0.963 Model explains 96.3% of price variance

SHAP Corr(SUM phi_i, f(x) - SHAP values are essentially exact for this
r = 0.999
Fidelity baseline) tree model

3.10 Fairness Audit — Detecting Redlining with XAI


Redlining is the illegal practice of denying services to residents of certain areas based on racial or
demographic characteristics. In AI-based property valuation, this can occur unintentionally if 'location
grade' encodes historical segregation patterns. XAI enables a fairness audit:
• Step 1: SHAP values are computed separately for properties in historically under-invested
neighborhoods vs. affluent areas.
• Step 2: If SHAP contributions for identical physical characteristics (same area, bedrooms,
age) produce significantly different prices based solely on neighborhood demographics —
this signals algorithmic redlining.
• Step 3: Feature attribution analysis is submitted to regulatory bodies (e.g., NHB in India) as
evidence of fairness compliance.
• Step 4: If bias is detected, the 'Location Grade' feature is decomposed into objective sub-
features (infrastructure score, school density, crime rate) to remove subjective bias.

Page 18 of 24 | XAI Study Notes — Elaborated Edition


Explainable Artificial Intelligence (XAI) | In-Depth Scenario Study: Medical Diagnosis & House Sale Prediction

Page 19 of 24 | XAI Study Notes — Elaborated Edition


Explainable Artificial Intelligence (XAI) | In-Depth Scenario Study: Medical Diagnosis & House Sale Prediction

4. Comparative Analysis: Both Scenarios


The two scenarios examined represent opposite ends of the stakes spectrum — one involving human
health, the other involving financial assets. Yet both scenarios share fundamental XAI requirements
and reveal how XAI is a domain-agnostic necessity in modern AI systems.

Dimension Scenario 1: Medical Diagnosis Scenario 2: House Sale Prediction

Real Estate / Fintech / Property


Domain Clinical Healthcare / Cardiology
Markets

XGBoost Binary Classifier (P(HIGH LightGBM Regression (₹ Lakhs


AI Model
RISK)) prediction)

Binary classification with probability


Output Type Continuous numerical price estimate
score

Primary Cardiologists, patients, hospital Buyers, sellers, mortgage banks,


Stakeholders administrators, FDA PropTech firms, regulators

XAI Techniques SHAP, PDP, Counterfactuals, Feature


SHAP, LIME, Grad-CAM, Anchors
Used Importance, LORE

Risk of Wrong Life-threatening — missed diagnosis Financial loss, discriminatory lending,


Decision or unnecessary treatment market distortion

Explanation Medical professionals + patients (dual Buyers, sellers, loan officers (financial
Consumer audience) audience)

Data Type Tabular (EHR) + Images (X-ray, ECG) Tabular only (property attributes)

FDA AI Guidance, EU AI Act, HIPAA, Fair Credit Reporting Act, RBI


Key Regulation
GDPR Guidelines, GDPR, NHB

Dominant XAI Transparency + Fairness + ROI


Trust + Safety + Clinical Validity
Goal Optimization

Mandatory — physician makes final Recommended — financial advisor or


Human Override
call loan officer reviews

Bias Type to Demographic bias (age, gender, Geographic bias (redlining,


Detect ethnicity in risk scoring) neighborhood segregation)

Lifestyle changes, medication, further Renovation, pricing strategy, listing


Actionability
tests optimization

Page 20 of 24 | XAI Study Notes — Elaborated Edition


Explainable Artificial Intelligence (XAI) | In-Depth Scenario Study: Medical Diagnosis & House Sale Prediction

5. XAI Tools, Libraries & Implementation


Multiple open-source libraries enable practical XAI implementation in Python. The table below
provides a comprehensive reference:

Use in Our
Library Technique Model Support Key Function
Scenarios

Any
(TreeSHAP, Both Scenario
shap SHAP [Link](model)
DeepSHAP, 1 and 2
KernelSHAP)

Scenario 1 —
Any (model-
lime LIME LimeTabularExplainer() tabular patient
agnostic)
data

Scenario 1 —
pytorch- GradCAM(model,
Grad-CAM PyTorch CNNs medical
gradcam target_layers)
imaging

Anchors, AnchorTabular(), Both


alibi Any
Counterfactuals Counterfactual() scenarios

Scenario 2 —
lore LORE Any LOREM(blackbox, dataset) rule
explanations

sklearn, Global feature


Permutation
eli5 XGBoost, explain_weights(model) importance —
Importance
LightGBM both

EBM Microsoft's Alternative to


InterpretML (Explainable glass-box ExplainableBoostingClassifier() XGBoost in
Boosting) model Scenario 1

Deep learning
Integrated PyTorch deep
Captum IntegratedGradients(model) variant for
Gradients learning
Scenario 1

5.1 Sample Python Code: SHAP for Medical Model

# Scenario 1: SHAP explanation for XGBoost cardiovascular risk model


import shap, xgboost, pandas as pd

features =
['Age','BloodPressure','Cholesterol','Glucose','BMI','Smoker','Exercise']
model = [Link]().fit(X_train, y_train)

explainer = [Link](model) # Fast exact SHAP for tree models


shap_values = explainer.shap_values(X_test) # Matrix: n_patients x n_features

Page 21 of 24 | XAI Study Notes — Elaborated Edition


Explainable Artificial Intelligence (XAI) | In-Depth Scenario Study: Medical Diagnosis & House Sale Prediction

# Explain prediction for patient P001 (index 0)


shap.waterfall_plot(explainer.expected_value, shap_values[0], X_test.iloc[0])

# Global importance: mean absolute SHAP values across all patients


shap.summary_plot(shap_values, X_test, feature_names=features)

Page 22 of 24 | XAI Study Notes — Elaborated Edition


Explainable Artificial Intelligence (XAI) | In-Depth Scenario Study: Medical Diagnosis & House Sale Prediction

6. Summary, Conclusions & Future Directions

6.1 Consolidated Lessons from Both Scenarios


Across both scenarios, three consistent themes emerge regarding the value and necessity of XAI:

1. Explanations must match the audience. A cardiologist needs feature-level SHAP values
mapped to clinical terminology. A first-time homebuyer needs a plain-language statement:
'Your home's price is ₹18L lower than comparable properties primarily because of its Grade
C location.' The XAI framework must translate model outputs into domain-appropriate
language.
2. Local explanations are more actionable than global ones. For both scenarios, knowing that
'Age is the most important global feature' is less useful than knowing 'For Patient P001,
blood pressure is the most important feature in this specific prediction.' LIME and SHAP
local explanations drive better decisions than global importance rankings alone.
3. XAI reveals what the model has and has not learned. The Grad-CAM heatmap for medical
imaging confirms the model is looking at the right anatomical region. The SHAP fairness
audit for house pricing reveals if the model has inadvertently learned discriminatory patterns.
XAI is both an explanation tool and a model debugging tool.

6.2 XAI Best Practices


• Always combine local (SHAP/LIME) and global (Feature Importance/PDP) explanations for a
complete picture
• Validate explanations with domain experts before deployment — a technically correct
explanation may be clinically misleading
• Monitor explanation drift: if SHAP values for a feature change significantly over time, the
model may be learning from distribution shift
• Provide tiered explanations: technical (for data scientists), domain-specific (for
professionals), and simplified (for end users)
• Log all explanations alongside predictions for auditability and regulatory compliance
• Test explanation consistency: run LIME multiple times and check that the most important
features remain stable

6.3 Future Directions of XAI


Direction Description

Moving from correlation-based SHAP to true causal explanations using DAGs


Causal XAI and structural causal models. E.g., 'Reducing BP causes a 0.15 reduction in
CVD risk' vs. 'BP is correlated with CVD risk.'

Generating XAI explanations from models trained on distributed private data


Federated XAI
(multiple hospitals, banks) without centralizing sensitive records.

Page 23 of 24 | XAI Study Notes — Elaborated Edition


Explainable Artificial Intelligence (XAI) | In-Depth Scenario Study: Medical Diagnosis & House Sale Prediction

LLMs translating SHAP/LIME outputs into conversational explanations: 'Your


Natural Language
blood pressure is 28mmHg above average and is the primary reason for your
XAI
HIGH RISK classification.'

Real-time dashboards where clinicians and buyers can run 'what-if' scenarios,
Interactive XAI adjust features, and see how the model prediction changes — powered by fast
SHAP/counterfactual backends.

XAI ISO/IEEE standards for XAI explanation formats, enabling interoperability


Standardization between different AI systems and explanation libraries across institutions.

XAI = Trustworthy AI + Human Understanding + Responsible Deployment

Page 24 of 24 | XAI Study Notes — Elaborated Edition

You might also like