शुरू करेंमुफ़्त में शुरू करें

Coefficients बनाम permutation importance

अब, आप heart disease डेटासेट पर प्रशिक्षित एक logistic regression के मॉडल coefficients के साथ permutation importance से मिले पैटर्न्स की तुलना करेंगे. स्क्रिप्ट के अंत में helper फंक्शन plot_importances() कॉल होता है ताकि एक ही plot पर importances दिखाए जा सकें.

X जिसमें features हैं और y जिसमें labels हैं, तथा logistic regression model आपके लिए पहले से लोड किए गए हैं. matplotlib.pyplot को plt नाम से इम्पोर्ट किया गया है.

यह अभ्यास पाठ्यक्रम का हिस्सा है

Python में Explainable AI

पाठ्यक्रम देखें

अभ्यास निर्देश

  • logistic regression model के coefficients निकालें.
  • random_state 1 के साथ 20 repeats पर permutation importance निकालें.
  • सभी repeats के पार औसत permutation importance निकालें.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

from sklearn.inspection import permutation_importance

# Extract and store model coefficients
coefficients = ____

# Compute permutation importance on the test set
perm_importance = ____

# Compute the average permutation importance
avg_perm_importance = ____

plot_importances(coefficients, avg_perm_importance)
कोड संपादित करें और चलाएँ