Tree-based model train করার পরে একটি common প্রশ্ন হলো:
কোন features model-এর prediction-এর জন্য সবচেয়ে গুরুত্বপূর্ণ?
এটি বোঝার জন্য বিভিন্ন ধরনের Feature Importance technique ব্যবহার করা হয়।
কিন্তু সব importance measure একই জিনিস বোঝায় না।
Gain / Impurity-based Importance
Decision Tree যখন কোনো feature ব্যবহার করে split করে, তখন সেই split prediction quality কতটা improve করেছে সেটা measure করা যায়।
যে feature repeatedly useful split তৈরি করে, তার importance বেশি হতে পারে।
Conceptually:
Feature used
→ Split created
→ Impurity / Loss reduced
→ Importance increased
Example
ধরুন fraud model-এ:
Transaction Amount → অনেক strong split
Device Age → কিছু useful split
Customer Name → প্রায় কোনো useful split না
তাহলে tree-based importance-এ:
Transaction Amount
বেশি important হতে পারে।
Limitation
Impurity-based importance misleading হতে পারে।
বিশেষ করে:
high-cardinality features favour করতে পারে
correlated features importance share করতে পারে
training data-এর importance generalization importance নাও হতে পারে
Permutation Importance
Permutation Importance একটি intuitive approach।
একটি feature-এর values randomly shuffle করি।
ফলে feature-এর relationship target-এর সাথে destroy হয়।
তারপর model performance আবার measure করি।
Intuition
ধরুন baseline model:
F1 = 0.82
transaction_amount shuffle করার পরে:
F1 = 0.61
Performance অনেক কমেছে।
তাই feature-টি important।
অন্যদিকে customer_color_preference shuffle করার পরে:
F1 = 0.819
Performance প্রায় unchanged।
তাহলে feature-টি model-এর জন্য খুব important ছিল না।
Core Idea
Shuffle feature
↓
Break its information
↓
Measure performance drop
↓
Large drop = More important
SHAP
SHAP একটি more detailed explanation technique।
এটি শুধু:
Which feature is globally important?
এই প্রশ্নের answer দেয় না।
এটি individual prediction-এর ক্ষেত্রেও বলতে পারে:
Which feature pushed this prediction up or down?
Example
ধরুন fraud model-এর base probability:
10%
একটি specific transaction-এর জন্য:
High transaction amount → +20%
New device → +15%
Known address → -5%
Conceptually final prediction:
≈ 40%
অর্থাৎ SHAP local explanation দিতে পারে।
Global vs Local Explanation
Global Importance
→ Overall model কোন features-এর উপর বেশি depend করে?
Local Explanation
→ একটি specific prediction কেন এমন হলো?
SHAP দুটোই analyze করতে সাহায্য করতে পারে।
Correlated Features নিয়ে সতর্কতা
ধরুন:
Feature A = Customer Age
Feature B = Birth Year
দুইটি highly correlated।
Model একই information দুই feature থেকে পেতে পারে।
তখন importance দুইটির মধ্যে ভাগ হয়ে যেতে পারে।
তাই feature importance interpretation করার সময় correlation consider করা উচিত।
সবচেয়ে গুরুত্বপূর্ণ Warning
Feature Importance ≠ Causality
একটি feature prediction-এর জন্য useful হওয়া মানে এই নয় যে feature-টি target-এর কারণ।
উদাহরণ:
Umbrella usage
rain prediction-এর সাথে strongly associated হতে পারে।
কিন্তু umbrella use করার কারণে বৃষ্টি হয় না।
Interview-ready Explanation
Feature importance measures how much a model relies on
different features for prediction.
Tree-based gain or impurity importance measures how much
a feature improves splits.
Permutation importance measures how much model performance
drops when a feature is shuffled.
SHAP can explain both global feature importance and the
contribution of individual features to specific predictions.
However, feature importance should not be interpreted
as causality, and correlated features can complicate
the interpretation.
সহজে মনে রাখুন:
Gain
→ How useful was the feature for tree splits?
Permutation
→ What happens if I destroy this feature?
SHAP
→ How did this feature contribute to this prediction?
Importance ≠ Causality