ट्री-आधारित मॉडलों में explainability

Python में Explainable AI

Fouad Trad

Machine Learning Engineer

Decision tree

  • ट्री-आधारित मॉडलों का मूल ब्लॉक
  • रिग्रेशन और क्लासिफिकेशन में उपयोग
  • प्रेडिक्शन के लिए ट्री-जैसी संरचना
    • कई निर्णय
    • हर निर्णय एक फीचर पर आधारित
  • स्वभावतः explainable

एक decision tree का चित्रण, जो दिखाता है कि कई conditions के आधार पर प्रेडिक्शन कैसे होते हैं

Python में Explainable AI

Random forest

  • कई decision trees से मिलकर बना
  • रिग्रेशन और क्लासिफिकेशन में उपयोग
  • सीधी व्याख्या को जटिल बनाता है
  • फीचर इम्पॉर्टेंस
    • प्रेडिक्शनों में अनिश्चितता की कमी को मापता है
    • लीनियर मॉडलों के coefficients से अलग

Random forest की छवि: कई पेड़ एक instance लेते हैं और प्रेडिक्शन समेकित कर अंतिम प्रेडिक्शन देते हैं.

Python में Explainable AI

Admissions डेटासेट

GRE Score TOEFL Score University Rating SOP LOR CGPA Accept
337 118 4 4.5 4.5 9.65 1
324 107 4 4 4.5 8.87 1
316 104 3 3 3.5 8.00 1
322 110 3 3.5 2.5 8.67 1
314 103 2 2 3 8.21 0
X_train = data.drop(['Accept'], axis=1)
y_train = data['Accept']
Python में Explainable AI

मॉडल प्रशिक्षण

from sklearn.tree import DecisionTreeClassifier

tree_model = DecisionTreeClassifier() tree_model.fit(X_train, y_train)
print(tree_model.feature_importances_)
[0.17936982 0.08878744 0.04388924 
 0.0532897  0.07130751 0.56335628]
from sklearn.ensemble import RandomForestClassifier

forest_model = RandomForestClassifier() forest_model.fit(X_train, y_train)
print(forest_model.feature_importances_)
[0.25347149 0.17518662 0.06551317 
 0.06758647 0.07866478 0.35957747]
Python में Explainable AI

फीचर इम्पॉर्टेंस

import matplotlib.pyplot as plt

plt.barh(X_train.columns, 
         tree_model.feature_importances_)
plt.title('Feature Importance - Decision Tree')
plt.show()

एक क्षैतिज बार प्लॉट, जो दिखाता है कि CGPA और GRE score सबसे महत्वपूर्ण फीचर्स हैं.

import matplotlib.pyplot as plt

plt.barh(X_train.columns, 
         forest_model.feature_importances_)
plt.title('Feature Importance - Random Forest')
plt.show()

एक क्षैतिज बार प्लॉट, जो दिखाता है कि CGPA और GRE score सबसे महत्वपूर्ण फीचर्स हैं.

Python में Explainable AI

अभ्यास करते हैं!

Python में Explainable AI

Preparing Video For Download...