Precision और Recall
Precision और recall, दोनों ही पिछले लेसन में चर्चा किए गए चार outcomes से जुड़े हैं और किसी भी मशीन लर्निंग मॉडल के लिए महत्वपूर्ण evaluation metrics हैं. एक ad CTR मॉडल में आदर्श रूप से उच्च precision (ad spend पर उच्च ROI) और recall (relevant audience targeting) होना चाहिए. हालाँकि precision और recall को हाथ से निकाला जा सकता है, sklearn में इनके उपयोगी implementations हैं जिन्हें आप आसानी से अपनी मौजूदा workflow में प्लग कर सकते हैं. इस अभ्यास में, आप एक decision tree सेट अप करेंगे और precision व recall की गणना करेंगे.
आपके workspace में pandas module pd नाम से उपलब्ध है और sample DataFrame df के रूप में लोड है. Features X में और target y में उपयोग के लिए लोड हैं. इसके अलावा, sklearn.metrics से precision_score() और recall_score() उपलब्ध हैं.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में Machine Learning के साथ CTR प्रेडिक्शन
अभ्यास निर्देश
Xऔरyके लिए training और testing splits प्राप्त करें.- एक decision tree classifier परिभाषित करें और मॉडल fit करके
y_predpredictions निकालें. - Precision और recall scores पाने के लिए
sklearnकी implementations का उपयोग करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Set up training and testing split
X_train, X_test, y_train, y_test = ____(
____, ____, test_size = .2, random_state = 0)
# Create classifier and make predictions
clf = ____
y_pred = clf.____(____, _____).____(X_test)
# Evaluate precision and recall
prec = ____(y_test, ____, average = 'weighted')
recall = ____(y_test, ____, average = 'weighted')
print("Precision: %s, Recall: %s" %(prec, recall))