क्लासिफ़ायर तुलना
ROI फ़्रेमवर्क को अलग-अलग क्लासिफ़ायर पर चलाकर देखा जा सकता है कि कैसे अधिक precision और recall से ROI मान बढ़ते हैं। ध्यान दें कि आपने जो बेसलाइन क्लासिफ़ायर बनाया था, उसका कुल रिटर्न और कॉस्ट 0 होगा क्योंकि डिज़ाइन के मुताबिक true positives tp और false positives fp दोनों 0 होंगे। इस अभ्यास में, आप ROI फ़्रेमवर्क का उपयोग करके logistic regression और decision tree क्लासिफ़ायर की तुलना करेंगे.
X_train, y_train, X_test, y_test आपके वर्कस्पेस में उपलब्ध हैं, साथ ही pandas pd के रूप में और numpy np के रूप में। sklearn.linear_model से LogisticRegression() भी उपलब्ध है.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में Machine Learning के साथ CTR प्रेडिक्शन
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Create and fit classifier
clf = ____
y_pred = clf.____(X_train, y_train).____(X_test)
# Calculate total return, total spent, and ROI
r, cost = 0.2, 0.05
tn, fp, fn, tp = ____(y_test, y_pred).____
total_return = ____ * r
total_spent = (____ + ____) * cost
roi = total_return / total_spent
print("Total return: %s, Total spent: %s, ROI: %s" %(total_return, total_spent, roi))