Acceptance rates
किसी acceptance rate को सेट करना और उस दर के लिए थ्रेशोल्ड निकालना, आप जितने नए लोन स्वीकार करना चाहते हैं उनका प्रतिशत तय करने में काम आता है। इस अभ्यास में मान लीजिए कि टेस्ट डेटा नए लोन का एक नया बैच है। आपको numpy की quantile() फंक्शन का उपयोग करके थ्रेशोल्ड निकालना है।
इस थ्रेशोल्ड का उपयोग नए loan_status मान असाइन करने के लिए करना चाहिए। क्या डेटा में डिफॉल्ट और नॉन-डिफॉल्ट की संख्या बदलती है?
ट्रेंड मॉडल clf_gbt और उसकी प्रेडिक्शंस वाला डेटा फ्रेम test_pred_df उपलब्ध हैं.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में क्रेडिट रिस्क मॉडलिंग
अभ्यास निर्देश
- प्रेडिक्शंस वाले डेटा फ्रेम में
prob_defaultकी summary statistics को.describe()से प्रिंट करें. 85%acceptance rate के लिएquantile()का उपयोग करके थ्रेशोल्ड निकालें और उसेthreshold_85के रूप में स्टोर करें.threshold_85के आधार परpred_loan_statusनाम का नया कॉलम बनाएँ.pred_loan_statusमें नए मानों के value counts प्रिंट करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Check the statistics of the probabilities of default
print(____[____].describe())
# Calculate the threshold for a 85% acceptance rate
____ = np.____(____['prob_default'], ____)
# Apply acceptance rate threshold
____[____] = ____[____].apply(lambda x: 1 if x > ____ else 0)
# Print the counts of loan status after the threshold
print(____[____].____())