পাঠ ২৬ · ৪৫-এর মধ্যে · মডিউল ৩
Home / AI Courses / Machine Learning / Feature Importance

Feature Importance বিশ্লেষণ

Feature importance — three approaches
৬ মিনিট পড়া মাঝারি · Intermediate sklearn + shap

এই পাঠে যা শিখবেন

  • MDI feature importance — কীভাবে compute, কোথায় bias
  • Permutation importance — model-agnostic alternative
  • SHAP values — game theory-based, per-prediction
  • Three method-এর strengths/weaknesses ও কখন কোনটি
  • Daraz / bKash / brac scenario-এ practical workflow

১ · কেন feature importance দরকার

মডেল accurate হলেই কাজ শেষ নয়। বহু কারণে feature importance critical:

  • Interpretation: "মডেল কেন এটা predict করল?" — stakeholder-কে explain।
  • Debug: অপ্রত্যাশিত feature top-এ → data leak ধরা।
  • Feature selection: least important features remove করে — simpler model।
  • Domain knowledge validation: expected feature important — sanity check।
  • Regulatory: Bangladesh Bank, GDPR, "right to explanation" — required।
  • Bias audit: protected attributes (gender, religion proxy) leak হচ্ছে কি?

২ · MDI — Mean Decrease in Impurity

Tree-based model-এর built-in importance। Algorithm:

  1. প্রতি split-এ — impurity reduction (Gini decrease বা MSE drop) calculate।
  2. Reduction-কে split-এর feature-কে credit দিন।
  3. সব trees-এ sum, normalize (sum to 1)।

Mathematically:

$$\text{MDI}(f) = \sum_{t \in \text{trees}} \sum_{n \in t : \text{split}(n) = f} \frac{|D_n|}{|D|} \Delta i(n)$$

সুবিধা:

  • Free — training-এর সাথে compute।
  • সব tree-based libraries-এ default।
  • Fast — O(trees × splits)।

সমস্যা:

  • High-cardinality bias: বহু unique value-যুক্ত features (continuous, customer_id) — অনেক split offer → inflated importance।
  • Training-only: overfit features-ও high MDI।
  • Direction lost: high vs low income — both contribute, MDI scalar।
  • Correlated features: importance শেয়ার — none individually correctly attributed।

৩ · Permutation Importance

Permutation importancePermutation Importanceএকটি feature-এর values randomly shuffle করে — model performance drop measure। Model-agnostic, validation set-এ usage — generalization-aware। Cardinality bias-free। Breiman (২০০১) introduce। — Breiman-এর elegant idea (২০০১)। Algorithm:

  1. Validation set-এ baseline performance measure (e.g., accuracy, AUC)।
  2. একটি feature $f$-এর values randomly shuffle (samples-এর across)।
  3. Shuffled validation-এ performance measure।
  4. $\text{Importance}(f) = \text{baseline} - \text{shuffled}$।
  5. প্রতি feature-এ পুনরাবৃত্তি, multiple shuffles average।

Logic: feature important হলে — shuffle করলে performance crash। Useless feature — shuffle করলে কিছুই বদলায় না।

সুবিধা:

  • Model-agnostic — যেকোনো model।
  • Validation-এ — generalization-aware।
  • Cardinality bias-free।
  • Direction-aware (sort of — shuffle effect)।

সমস্যা:

  • Computational cost: $O(n_{\text{features}} \times n_{\text{shuffles}})$।
  • Correlated features: still issue — one shuffle, other কাজ চালু রাখে।
  • Out-of-distribution shuffle: unrealistic combinations create — extrapolation error।

৪ · SHAP — game theory perspective

SHAPSHAP (SHapley Additive exPlanations)Lundberg & Lee (২০১৭)। Shapley values (game theory) ML-এ apply। Per-prediction fair attribution — coalition game-এ player-এর contribution analog। TreeExplainer — tree models-এ fast। (SHapley Additive exPlanations) — Lundberg & Lee (২০১৭)। Game theory-এর Shapley values-এর ML application।

Shapley value (Shapley, ১৯৫৩): coalition game-এ player-এর fair share। Average marginal contribution — সব possible orderings-এ।

ML-এ:

$$\phi_i = \sum_{S \subseteq F \setminus \{i\}} \frac{|S|! (|F| - |S| - 1)!}{|F|!} \left[f_x(S \cup \{i\}) - f_x(S)\right]$$

  • $F$ — সব features।
  • $S$ — subset of features।
  • $f_x(S)$ — শুধু $S$ feature-এ trained model-এর prediction।
  • $\phi_i$ — feature $i$-এর Shapley value।

Properties (mathematical):

  • Efficiency: $\sum_i \phi_i = f(x) - E[f]$ — sum equals total prediction।
  • Symmetry: equivalent features → same value।
  • Dummy: useless feature → 0।
  • Additivity: ensemble model-এ — component sum।

সুবিধা:

  • Per-prediction explanation।
  • Direction (positive/negative contribution)।
  • Mathematically grounded।
  • TreeExplainer — fast for tree models।

সমস্যা:

  • Compute expensive (general case)।
  • Tree-specific fast version exists।
  • Causal interpretation careful।
  • Correlated features — assignment ambiguous।
তিনটি Feature Importance পদ্ধতি ১. MDI (built-in) Gini reduction sum Speed: ⚡⚡⚡⚡ Direction: ❌ Cardinality bias: ❌ Validation-aware: ❌ Per-sample: ❌ কখন: - Quick screening - First read - Tree-based only ⚠ trust-এ careful ২. Permutation Shuffle & measure drop Speed: ⚡⚡ Direction: ❌ Cardinality bias: ✅ Validation-aware: ✅ Per-sample: ❌ কখন: - Reliable global - Model-agnostic - Production sanity ✓ Default reliable ৩. SHAP Game theory attribution Speed: ⚡⚡⚡ (Tree fast) Direction: ✅ Cardinality bias: ✅ Validation-aware: ✅ Per-sample: ✅ কখন: - Per-customer - Regulator audit - Final report ✓ Gold standard
তিনটি পদ্ধতি — MDI fast quick read, Permutation reliable global, SHAP per-prediction gold standard। Production-এ — তিনটিই use করুন।

৫ · Python — তিনটি পদ্ধতি একসাথে

Python · sklearn + shap
import numpy as np
from sklearn.ensemble import RandomForestClassifier
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split
from sklearn.inspection import permutation_importance

X, y = load_breast_cancer(return_X_y=True)
feat_names = load_breast_cancer().feature_names
Xt, Xv, yt, yv = train_test_split(X, y, test_size=0.3, random_state=0)

rf = RandomForestClassifier(n_estimators=200, random_state=0).fit(Xt, yt)

# 1) MDI
mdi = sorted(zip(rf.feature_importances_, feat_names), reverse=True)
print("MDI top 5:")
for imp, name in mdi[:5]:
    print(f"  {name}: {imp:.4f}")

# 2) Permutation
perm = permutation_importance(rf, Xv, yv, n_repeats=10, random_state=0, n_jobs=-1)
perm_sorted = sorted(zip(perm.importances_mean, feat_names), reverse=True)
print("\nPermutation top 5:")
for imp, name in perm_sorted[:5]:
    print(f"  {name}: {imp:.4f}")

# 3) SHAP (TreeExplainer — fast for trees)
import shap
explainer = shap.TreeExplainer(rf)
shap_values = explainer.shap_values(Xv)
# For binary class — shap_values is list of 2 arrays
if isinstance(shap_values, list):
    sv = shap_values[1]  # positive class
else:
    sv = shap_values
shap_imp = np.abs(sv).mean(axis=0)
shap_sorted = sorted(zip(shap_imp, feat_names), reverse=True)
print("\nSHAP top 5:")
for imp, name in shap_sorted[:5]:
    print(f"  {name}: {imp:.4f}")

    
তিনটি method — top features প্রায়ই overlap। যেখানে differ — সেটা যাচাইযোগ্য signal। Production-এ — তিনটির consensus features-এ trust।

৬ · SHAP per-prediction explanation

Python · shap
# প্রতি sample-এর জন্য explanation
import shap
explainer = shap.TreeExplainer(rf)

# একটি specific patient
i = 5
shap_vals_i = explainer.shap_values(Xv[i:i+1])
print(f"Patient {i} prediction: {rf.predict_proba(Xv[i:i+1])[0]}")
print(f"Top contributing features:")

if isinstance(shap_vals_i, list):
    sv = shap_vals_i[1][0]  # positive class
else:
    sv = shap_vals_i[0]

# Sort by absolute SHAP value
order = np.argsort(np.abs(sv))[::-1]
for j in order[:5]:
    sign = '+' if sv[j] > 0 else '-'
    print(f"  {feat_names[j]} = {Xv[i, j]:.2f} → {sign}{abs(sv[j]):.4f}")

    
Per-patient explanation — clinician/customer-কে show করতে পারেন। Banking-এ — কেন loan approved/rejected-এর justification।

৭ · Practical workflow

  1. Train model + record built-in MDI।
  2. Quick MDI scan: top 20। Suspicious (e.g., customer_id) — ধর।
  3. Permutation: validation-এ — top 10 যাচাই। MDI overinflated features filter।
  4. SHAP global: top 5 narrative-এ include।
  5. SHAP local: selected predictions — explanation report।
  6. Domain expert: top features sensible? Bias check।
  7. Iterate: low-importance features remove → simpler model।

৮ · Common pitfalls

  • Causation confusion: "important" ≠ "causes"। Confounders এড়ান।
  • Correlated features: importance split — single feature undervalued।
  • OOD shuffles: permutation-এ unrealistic combinations — error inflated।
  • Single seed: importance variance — multiple seeds avg।
  • MDI alone: never! cross-validate দিয়ে other methods।
  • Stable across folds? CV-এ importance vary করলে — model unstable।
Feature importance — single number scientific reality না। Multi-method, domain-aware, contextual interpretation।

ভাবনার প্রশ্ন

প্রতিটি প্রশ্ন নিজে কিছুক্ষণ ভাবুন — তারপর "→ উত্তর" চাপুন।

প্র ০১ "Feature important" ≠ "feature causes" — এই পার্থক্য কতটা critical? ML production-এ causal feature কীভাবে identify করেন?

Correlation vs causation — ML interpretation-এর deepest pitfall। Production decision-এ critical।

"Important" vs "Causes":

  • Important: prediction-এ contribute করে।
  • Causes: intervention করলে outcome বদলায়।
  • Often coincide, often না।

Spurious correlation example:

  • Hospital — "ER door distance" loan default predict।
  • Reason: poor area, hospital remote।
  • Distance → default — confounded by poverty।
  • Intervention (move door) → default unchanged।

Confounding sources:

(১) Common cause:

  • X ← Z → Y।
  • X ও Y correlated, but X-এ intervention Y unchanged।
  • Classic confounder।

(২) Selection bias:

  • Sampling — outcome-affected।
  • Survivor bias।
  • Models bias inherit।

(৩) Reverse causation:

  • X ← Y mistakenly X → Y।
  • "Sick → fewer steps" but "fewer steps → sick" mistakenly।

(৪) Mediator:

  • X → Z → Y।
  • Z important predictor, but causal path through X।
  • Removing X → Z disrupts।

Why it matters in production:

(১) Action-prediction mismatch:

  • "Income high — approve" — predict good।
  • "Approve everyone with high income" — feedback loop।
  • System self-fulfilling।

(২) Distribution shift:

  • Spurious correlation environment-specific।
  • New environment — break।
  • Causal feature stable।

(৩) Adversarial attack:

  • Spurious feature gameable।
  • Causal feature harder to fake।

(৪) Fairness:

  • Protected attribute proxy → unfair।
  • Causal analysis discriminate।

Identifying causal features:

(১) Domain knowledge:

  • Subject matter expert।
  • Causal mechanism plausibility।
  • "Does it make sense?"।

(২) Randomized experiments (RCT):

  • Gold standard।
  • Random assignment break confounding।
  • A/B test in tech।
  • Expensive, ethical issue.

(৩) Natural experiments:

  • Quasi-random variation।
  • Policy change, lottery।
  • Instrumental variables।

(৪) Causal inference methods:

  • Propensity score matching।
  • Difference-in-differences।
  • Regression discontinuity।
  • Synthetic control।

(৫) DAG (Directed Acyclic Graph):

  • Pearl's framework।
  • Causal structure model।
  • do-calculus।
  • Conditional independence test।

(৬) Stability across environments:

  • Multiple datasets।
  • Causal — stable।
  • Spurious — environment-specific।

(৭) Counterfactual reasoning:

  • "What if X were different?"।
  • Causal model required।

Practical workflow:

  • (১) ML model — predictive accurate।
  • (২) SHAP — important features।
  • (৩) Domain review — plausibility।
  • (৪) A/B test — high-stakes decisions।
  • (৫) Monitor — performance environment-stable?

Bangladesh examples:

(১) Microfinance:

  • "Mobile balance high → repay good"।
  • Income proxy or causal?
  • Intervention (mobile recharge subsidy) — repay unchanged।
  • Spurious।

(২) Healthcare:

  • "Hospital A patient — better outcome"।
  • Hospital quality or referral pattern?
  • Sicker patients to specialty hospitals।
  • Confounding।

(৩) Education:

  • "Tablet usage → score high"।
  • Tablet causal or motivated parents-এর proxy?
  • Confounded — parental investment।

মূল উপলব্ধি: ML predicts, causation requires more। Critical decisions — causal analysis essential। SHAP "important" — starting point, not final answer। Pearl, Imbens, Rubin — modern causal inference foundation।

প্র ০২ SHAP values mathematical-ly elegant। কিন্তু compute expensive। Tree-specific TreeExplainer কীভাবে কাজ করে এবং exact কেন possible?

TreeExplainer — Lundberg, Erion, Lee (২০১৮) — tree-specific exact polynomial-time algorithm। SHAP-এর scalability breakthrough।

Generic SHAP problem:

  • Shapley values — exponential subsets।
  • $|F|$ features → $2^{|F|}$ subsets।
  • 10 features → 1024 evaluations।
  • 50 features → 10¹⁵ — infeasible।

Approximation methods:

  • KernelSHAP — sample subsets।
  • Linear regression-এ exact।
  • NN-এ DeepSHAP।
  • Approximation accuracy issue।

TreeExplainer exact tree-এ — কেন possible:

(১) Tree structure exploit:

  • Path from root to leaf — feature subset implicit।
  • Decision sequence — Shapley contribution decompose।
  • Smart aggregation।

(২) Polynomial complexity:

  • $O(TLD^2)$ — T trees, L leaves, D depth।
  • 1000 trees, 100 leaves, depth 10 — feasible।
  • 1 second-এ explanations।

Algorithm intuition:

  • প্রতি tree-এ — sample-এর leaf path determine।
  • Path-এ features — actual সিদ্ধান্ত।
  • Other features — "missing" treatment।
  • Conditional expectation calculate।

Mathematical foundation:

  • $\phi_i = \mathbb{E}[f(X) | X_i = x_i] - \mathbb{E}[f(X)]$ averaging over subsets।
  • Tree path-এ — exact conditional expectation।
  • Recursive formulation।

Implementation tricks:

(১) Cover-based weighting:

  • প্রতি split-এ — sample fraction।
  • Weighted average।
  • Background distribution-এর approximation।

(২) Path tracking:

  • Single pass — all features simultaneously।
  • Memory-efficient।
  • Cache-friendly।

(৩) Two interventional modes:

  • Path-dependent: tree's training distribution।
  • Interventional: background dataset।
  • Different interpretation।

Two TreeSHAP variants:

  • "feature_perturbation='tree_path_dependent'": default fast।
  • "feature_perturbation='interventional'": uses background data, slower but more correct for correlated features।

Performance benchmark:

  • 10K samples, 50 features, 1000 trees।
  • KernelSHAP — minutes per sample।
  • TreeSHAP — seconds for all।
  • 1000× speedup typical।

Production deployment:

  • Pre-compute SHAP for batch — cache।
  • Real-time — TreeSHAP fast enough।
  • Per-prediction explanation feasible।

Limitations:

  • Tree models only।
  • Path-dependent assumption — correlated features distort।
  • Interventional mode — slow।
  • Approximate for complex models (e.g., XGBoost gain output)।

Visualization tools:

  • summary_plot: global importance।
  • force_plot: per-prediction।
  • dependence_plot: feature-target relationship।
  • waterfall: step-by-step।

Code example:

import shap
explainer = shap.TreeExplainer(model)
shap_values = explainer.shap_values(X)

# Global
shap.summary_plot(shap_values, X)

# Local
shap.force_plot(explainer.expected_value, shap_values[0], X[0])

# Dependence
shap.dependence_plot('age', shap_values, X)

Common pitfalls:

  • Multi-class output — list of arrays।
  • XGBoost direct vs sklearn wrapper — different formats।
  • Probability vs log-odds output।
  • Background dataset selection।

Beyond TreeSHAP:

  • DeepSHAP — neural networks।
  • GradientSHAP — gradient-based।
  • KernelSHAP — model-agnostic।
  • FastSHAP — neural approximator।

Bangladesh context:

  • Loan approval — per-customer SHAP।
  • Disease diagnosis — clinician explanation।
  • Fraud detection — investigator narrative।
  • Regulatory — audit trail।

মূল উপলব্ধি: TreeSHAP — tree models-এ revolutionary। Exact, fast, scalable। Production explanation-এর gold standard tabular ML-এ।

প্র ০৩ Correlated features — feature importance-এ সবচেয়ে বড় challenge। তিনটি method-এ এই issue কীভাবে manifest হয়, এবং practical mitigation কী?

Correlated features — production data-এর ubiquitous reality। Importance interpretation-এ careful navigation।

Real-world correlation examples:

  • Income, education, occupation — all correlated।
  • Height, weight, BMI — derived।
  • Age, retirement_savings, years_employed।
  • Login_count, page_views, session_time।

Impact-by-method:

(১) MDI (split-based):

  • Tree split — first available feature।
  • Correlated other — reduced importance।
  • Order arbitrary।
  • Different runs — flip results।

(২) Permutation:

  • Shuffle one — other carries information।
  • Performance drop minimal।
  • Both appear unimportant।
  • Mutual information masked।

(৩) SHAP:

  • Path-dependent — split-based, similar MDI issue।
  • Interventional — Shapley axiom — symmetry property।
  • Equal correlated → equal SHAP।
  • Better but ambiguous attribution।

Concrete example:

  • $X_1$, $X_2$ perfectly correlated।
  • $y = X_1 + \epsilon$।
  • Model: equally use both।
  • MDI: 50-50 (random)।
  • Permutation: both 0।
  • SHAP: 50-50।
  • True importance ambiguous।

Why this matters:

  • "Important features" misleading।
  • Feature selection — wrong choice।
  • Domain interpretation distorted।
  • Action recommendations flawed।

Mitigation strategies:

(১) Correlation analysis first:

  • Pearson, Spearman correlation matrix।
  • VIF (variance inflation factor)।
  • Pairs > 0.9 — flag।
  • Domain decision — keep both vs one।

(২) Group importance:

  • Correlated cluster — single group treat।
  • Permutation — group all shuffle।
  • Combined importance reveal।

(৩) Drop-column importance:

  • Feature drop, retrain।
  • Performance drop measure।
  • True marginal contribution।
  • Slow but accurate।

(৪) Conditional permutation:

  • Within similar groups shuffle।
  • Correlation preserved।
  • More realistic counterfactual।
  • "Stratified shuffle"।

(৫) Feature engineering:

  • Derive uncorrelated features।
  • PCA decomposition।
  • Residualize one against others।

(৬) Hierarchical clustering:

  • Correlation distance matrix।
  • Cluster correlated features।
  • Per-cluster representative।

(৭) Stable selection:

  • Multiple bootstrap samples।
  • Per-sample importance compute।
  • Consistency frequency measure।
  • Stable features trust।

(৮) Partial Dependence:

  • Marginal effect plot।
  • One feature varied, others held।
  • Direction & nonlinearity reveal।

(৯) ALE (Accumulated Local Effects):

  • PDP-এর correlated alternative।
  • Local effects accumulate।
  • Better correlation handling।

(১০) Domain-driven selection:

  • Causal mechanism understand।
  • Upstream/downstream identify।
  • Direct cause prefer।

Code example — group analysis:

from sklearn.cluster import AgglomerativeClustering
import numpy as np

# Correlation distance
corr = np.corrcoef(X.T)
dist = 1 - np.abs(corr)
clustering = AgglomerativeClustering(distance_threshold=0.3,
                                     n_clusters=None).fit(dist)
groups = clustering.labels_

# Per-group permutation
from sklearn.inspection import permutation_importance
for g in np.unique(groups):
    cols = np.where(groups == g)[0]
    # Shuffle entire group together
    Xv_p = Xv.copy()
    Xv_p[:, cols] = np.random.permutation(Xv_p[:, cols])
    drop = rf.score(Xv, yv) - rf.score(Xv_p, yv)
    print(f"Group {g} (cols {cols.tolist()}): drop {drop:.4f}")

Common production strategy:

  • Initial: correlation pairs identify।
  • Decision: keep both vs one।
  • Importance: per-group analysis।
  • Communication: caveat about correlated features।

Bangladesh examples:

  • Income, expenditure — correlated।
  • Mobile balance, mobile recharge — correlated।
  • Education years, occupation — correlated।
  • District, language — correlated।

মূল উপলব্ধি: Correlation — silent feature importance distortion। Multi-method validation critical। Domain knowledge often resolve interpretation। Group importance practical solution।

প্র ০৪ আপনি একটি Bangladesh fintech-এ regulator-এর কাছে loan rejection explain করতে হবে। SHAP report কীভাবে structure করবেন? সম্ভাব্য পক্ষপাত-এর audit?

Regulator-facing ML explanation — Bangladesh fintech-এর emerging challenge। SHAP — primary tool, কিন্তু presentation matter।

Regulator priorities:

  • Fairness: protected attribute discrimination?
  • Transparency: decision explainable?
  • Consistency: similar applicants — similar treatment?
  • Auditability: reproducible decisions?
  • Documentation: model lifecycle traceable?

SHAP report structure:

(১) Executive summary:

  • Model purpose, scope।
  • Data sources, time period।
  • Performance metrics overall।
  • Approval/rejection rates।
  • Per-segment fairness।

(২) Global feature importance:

  • Top 20 features SHAP global।
  • Permutation importance cross-check।
  • Domain rationale per feature।
  • Visualization: bar chart, beeswarm।

(৩) Per-decision explanation:

  • Sample rejected loan SHAP waterfall।
  • Top 5 contributing factors (positive)।
  • Top 5 contributing factors (negative)।
  • Total decision score।
  • Threshold rationale।

(৪) Counterfactual:

  • "কী বদলালে approved হত?"।
  • Minimum changes calculate।
  • Actionable advice for customer।
  • "Right to explanation" satisfaction।

(৫) Sensitivity analysis:

  • Feature value ±10% — score change।
  • Decision robust?
  • Boundary cases identify।

(৬) Subgroup performance:

  • Per-district approval rate।
  • Per-gender।
  • Per-age group।
  • Per-religion (proxy)।
  • Statistical parity check।

(৭) Disparate impact:

  • 80% rule (US fair lending analog)।
  • Group A approval rate / Group B।
  • < 80% — flag।
  • Bangladesh-specific groups।

(৮) Calibration:

  • Predicted probability vs actual default rate।
  • Per-group calibration।
  • Reliability diagram।

Bias audit framework:

(১) Direct discrimination:

  • Protected attributes used directly?
  • Religion, gender, ethnicity feature?
  • Bangladesh law — any of these flag।

(২) Indirect (proxy):

  • Surrogate features?
  • Name → religion proxy।
  • District → ethnicity proxy।
  • Phone area code → location proxy।

(৩) Outcome disparity:

  • Per-group rejection rate।
  • Significant disparity?
  • Statistical significance test।

(৪) Treatment disparity:

  • Same applicant profile, different group।
  • Different decision?
  • Counterfactual fairness।

Bias mitigation:

(১) Pre-processing:

  • Reweighing samples।
  • Massaging labels।
  • Synthetic data generation।

(২) In-processing:

  • Fairness constraints during training।
  • Adversarial debiasing।
  • Multi-objective loss।

(৩) Post-processing:

  • Threshold per-group adjust।
  • Equal opportunity।
  • Calibration adjust।

Documentation requirements:

  • Model card: Google template।
  • Data sheet: sources, collection, biases।
  • Validation report: performance, fairness।
  • Audit trail: per-decision SHAP cache।
  • Version control: model lifecycle।

Bangladesh-specific:

(১) Regulatory landscape:

  • Bangladesh Bank — emerging guidelines।
  • Personal Data Protection Bill।
  • Microcredit Regulatory Authority।
  • Anti-discrimination evolving।

(২) Cultural considerations:

  • Religion sensitivity (Eid, Ramadan)।
  • Geographic disparity (urban-rural)।
  • Linguistic (Bangla literacy)।
  • Gender norms।

(৩) Practical challenges:

  • Limited credit bureau data।
  • Informal economy participation।
  • Mobile money pattern changes।
  • COVID-induced shifts।

Customer-facing explanation:

  • Simple language (Bangla)।
  • Top 3 reasons-clear।
  • Actionable improvements।
  • Appeal process।
  • Cultural sensitivity।

Sample customer letter:

প্রিয় গ্রাহক,
আপনার ঋণ আবেদনটি আমরা গ্রহণ করতে পারিনি।
প্রধান কারণসমূহ:
১. গত ৬ মাসে আপনার মাসিক ব্যাংক স্থিতি গড়ে ১৫,০০০ টাকার নিচে ছিল।
২. আপনার আগের ঋণে ৯০ দিনের বেশি বিলম্ব হয়েছিল (২০২৪)।
৩. বর্তমান EMI আপনার আয়ের ৬০%-এর বেশি হবে।

পুনরায় আবেদনের জন্য — ৬ মাস consistent income পরে।
যোগাযোগ: support@bank.com

Tech stack:

  • SHAP library — explanation generate।
  • MLflow — version tracking।
  • Aequitas — fairness audit।
  • Evidently AI — drift monitoring।
  • Custom dashboard — regulator review।

Process recommendations:

  • Quarterly fairness audit।
  • Annual model revalidation।
  • Continuous monitoring।
  • External independent review।
  • Customer feedback loop।

মূল উপলব্ধি: Regulator-facing ML — algorithm 30%, governance 70%। SHAP — primary tool, কিন্তু process equally critical। Bangladesh fintech — emerging field, proactive compliance competitive advantage।

অনুশীলন

  1. হিসাব করুন: 3-feature model। SHAP values = (+0.3, -0.1, +0.2)। Baseline (E[f]) = 0.5। Final prediction কত?
    • Efficiency: $\sum \phi = f(x) - E[f]$।
    • $0.3 - 0.1 + 0.2 = 0.4$।
    • Final: $0.5 + 0.4 = 0.9$।
    • Strong positive prediction।
  2. Permutation: sklearn-এর breast cancer-এ — RF train, MDI ও permutation importance compare।
    from sklearn.inspection import permutation_importance
    perm = permutation_importance(rf, Xv, yv, n_repeats=10, random_state=0)
    # Top by MDI vs permutation প্রায়ই overlap, কিছু rank পরিবর্তন।
  3. চিন্তা: "Customer_id top SHAP feature" — কী indicate করে? ৩টি possible explanation।

    (১) Data leak — id-এ outcome encoded। (২) Time-correlation — id sequential, time-trend captured। (৩) Domain-specific id structure (e.g., region prefix) — but feature name misleading। সব ক্ষেত্রে — feature engineering revisit।

আরও পড়ুন

কোড রানার কাজ না করলে? Google Colab ব্যবহার করুন।
পূর্ববর্তী পাঠ
পাঠ ২৫ · LightGBM ও CatBoost