बेसलाइन
किसी classifier का उचित बेसलाइन के सापेक्ष मूल्यांकन करना महत्वपूर्ण है। यह विशेष रूप से imbalanced डेटासेट्स (जैसे ad click-through) के लिए सच है, क्योंकि केवल majority class चुनते रहने से उच्च accuracy आसानी से मिल सकती है। इस अभ्यास में, आप एक बेसलाइन classifier का सिमुलेशन करेंगे जो हमेशा majority class (non-click) की भविष्यवाणी करता है, और उसकी confusion matrix देखेंगे, साथ ही उसकी precision और recall क्या हैं, यह भी जानेंगे।
X_train, y_train, X_test, y_test आपके वर्कस्पेस में उपलब्ध हैं। pandas pd के रूप में, numpy np के रूप में, और sklearn भी आपके वर्कस्पेस में उपलब्ध हैं.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में Machine Learning के साथ CTR प्रेडिक्शन
अभ्यास निर्देश
np.asarray()का उपयोग करकेX_testकी समान लंबाई वाला शून्यों का एक arrayy_predबनाएँ.- प्राप्त confusion matrix प्रिंट करें.
- precision और recall स्कोर निकालें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Set up baseline predictions
y_pred = np.____([0 for x in range(len(X_test))])
# Look at confusion matrix
print("Confusion matrix: ")
print(____(y_test, y_pred))
# Check precision and recall
prec = ____(y_test, y_pred, average = 'weighted')
recall = ____(y_test, y_pred, average = 'weighted')
print("Precision: %s, Recall: %s" %(prec, recall))