🤖 AI/ML

Explainability

Explainability

The ability to explain an AI decision-making process in a way humans can understand. A core goal of the XAI field.

📖 Detailed Explanation

Explainability is the ability of an AI system to present the reasons for a particular decision in a way that humans can understand. Rather than simply providing a result, the key is to transparently show the process and rationale that led to it. This is the core goal of the field of XAI (Explainable AI).

Explainability matters for several reasons. First, in terms of regulatory compliance, the EU AI Act and the GDPR explicitly provide for a right to explanation regarding automated decision-making. When AI is used in healthcare, finance, and law, legal problems may arise if it cannot be explained why a particular judgment was made. It is also essential for building user trust and for model debugging.

There are major techniques for implementing explainability. LIME (Local Interpretable Model-agnostic Explanations) explains individual predictions by building a simple interpretable model. SHAP (SHapley Additive exPlanations) uses Shapley values from game theory to calculate the contribution of each feature. Attention visualization shows which inputs a Transformer model focused on.

Explainability is distinct from interpretability. Interpretability means that a model is understandable because it is itself simple (e.g., linear regression, decision trees), while explainability means interpreting the output of a complex model post hoc. In practice, both concepts should be considered together to establish model selection and explanation strategies.

Code Example

This is an example of explaining a model using SHAP.

import shap
import xgboost as xgb
from sklearn.datasets import load_boston
from sklearn.model_selection import train_test_split

# 데이터 로드 및 모델 학습
X, y = load_boston(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
model = xgb.XGBRegressor(n_estimators=100)
model.fit(X_train, y_train)

# SHAP Explainer 생성
explainer = shap.TreeExplainer(model)
shap_values = explainer.shap_values(X_test)

# 전역 특성 중요도 시각화
shap.summary_plot(shap_values, X_test)

# 개별 예측 설명 (첫 번째 샘플)
shap.force_plot(
    explainer.expected_value,
    shap_values[0],
    X_test[0]
)

# Waterfall plot으로 상세 분석
shap.plots.waterfall(shap.Explanation(
    values=shap_values[0],
    base_values=explainer.expected_value,
    data=X_test[0]
))

Performance & Cost

XAI Technique Computational Complexity Explanation Quality Use case
SHAP (TreeExplainer) O(TLD) High (theoretical foundation) Tree-based models
SHAP (KernelExplainer) O(2^M) approximation High All models (slow)
LIME O(NM) Medium Explains individual predictions
Attention visualization O(1) additional cost Medium Transformer models
Feature Importance O(M) Low Fast global analysis

🗣️ Say It Like This in Practice

"This model has achieved explainability using SHAP values. We can show quantitatively how much each feature contributed to the prediction."

In English, you would say "We've ensured explainability using SHAP values for this model." Terms such as "model interpretability", "feature attribution", and "prediction explanation" are also frequently used. In regulatory response meetings, mention whether the "Right to Explanation" is being complied with.

⚠️ Common Mistakes & Cautions

  • 1. Ignoring the trade-off between accuracy and explainability: Complex models are more accurate but harder to explain. Strike a balance that fits the domain requirements.
  • 2. Confusing global vs. local explanations: Explaining the whole model (global) and explaining individual predictions (local) are different. Choose according to your purpose.
  • 3. Excessive simplification: Explaining complex nonlinear relationships solely with simple Feature Importance can lead to misunderstanding.
  • 4. Underestimating computational cost: SHAP KernelExplainer is very slow. In production, consider batch processing or approximation techniques.
  • 5. Ignoring user context: Explanations for engineers and for general users should differ. Adjust the level of explanation to the audience.

🔗 Related Terms

📚 Learn More