🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to Machine Learning Notes
Topic #226

Global vs Local Explanations

Every explainability technique answers one of two fundamentally different questions: "how does this model behave overall?" (global) or "why did the model make this one prediction?" (local) — picking the wrong scope for your actual question is a common, avoidable mistake.

The Core Distinction

Global ExplanationLocal Explanation
Question answeredWhat does the model rely on overall, across all predictions?Why did the model predict this specific outcome for this specific input?
Example question"Which features matter most for churn prediction generally?""Why was this specific customer's churn risk predicted at 85%?"
AudienceData scientists, model developers, general stakeholdersAn individual affected by a specific decision, a support agent, an auditor of one case

Which Techniques Serve Which Scope

TechniqueGlobal?Local?
Permutation ImportanceYesNo
Random Forest's built-in feature_importances_YesNo
LIMENoYes
SHAPYes (aggregated)Yes (per instance)
Linear model coefficientsYesPartially — same coefficient applies everywhere, but its contribution to a specific prediction can still be computed

A Worked Illustration of Why Scope Matters

# GLOBAL: "which features matter most for the model overall?"
from sklearn.inspection import permutation_importance
result = permutation_importance(model, X_val, y_val, n_repeats=10)
# -> one importance ranking, describing the model's OVERALL behavior

# LOCAL: "why did the model predict THIS customer will churn?"
import shap
explainer = shap.TreeExplainer(model)
shap_values = explainer.shap_values(X_val.iloc[[42]])   # just ONE row
# -> a feature-by-feature breakdown for THIS SPECIFIC prediction, which may
# look very different from the global importance ranking above

A feature can rank low in global importance (rarely influential overall) while still being the dominant factor for one specific, unusual prediction — global and local explanations genuinely can, and often do, tell different stories, and neither one is "wrong."

Choosing the Right Scope for a Real Situation

SituationRight Scope
Explaining model behavior to a technical team for debuggingGlobal
Explaining one loan denial to the specific applicantLocal
Deciding which features are safe to drop for a simpler modelGlobal
Auditing a single, unusual/flagged predictionLocal

Practical Use Cases

  • Correctly matching an explainability request (from a stakeholder, regulator, or teammate) to the right technique and scope
  • Recognizing when a global summary alone won't satisfy a request that's actually asking about one specific case

Common Mistakes

  • Answering "why did the model deny this specific application?" with a global feature importance chart — the global ranking may not reflect what actually drove this one case.
  • Assuming a locally important feature for one prediction must also be globally important overall — the two scopes can disagree, and both can be simultaneously correct.

Interview Relevance

Q: "A stakeholder asks 'why did the model deny this customer's loan?' Which explainability approach do you use?" A local explanation (SHAP for that specific instance, or LIME) — this question is about one specific prediction, not the model's overall behavior, so a global feature importance ranking would answer a different question than the one actually being asked.

Practice Question

Explain a realistic scenario where a feature ranks low in global permutation importance but has a large SHAP value for one specific prediction.

Want to go beyond the notes?

Join CodingNow 2.0's Machine Learning course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Global vs Local Explanations – FAQs

Quick answers about learning Global vs Local Explanations in Machine Learning.

This free note from CodingNow 2.0 explains Global vs Local Explanations in Machine Learning — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every Machine Learning topic on CodingNow 2.0, including Global vs Local Explanations, is 100% free with no signup required.
With focused practice, most students grasp Global vs Local Explanations in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now