Precision, ROI, and AUC
The return on investment (ROI) can be decomposed into the precision multiplied by a ratio of return to cost. As discussed, it is possible for the precision of a model to be low, even while AUC of the ROC curve is high. If the precision is low, then the ROI will also be low. In this exercise, you will use a MLP to compute a sample ROI assuming a fixed r, the return on a click per number of impressions, and cost, the cost per number of impressions, along with precision and AUC of ROC curve values to check how the three values vary.
X_train, y_train, X_test, y_test are available in your workspace, along with clf as a MLP classifier, probability scores stored in y_score and predicted targets in y_pred. pandas as pd and sklearn are also available in your workspace.
Este exercício faz parte do curso
Predicting CTR with Machine Learning in Python
Instruções do exercício
- Calculate the precision
precof the MLP classifier. - Calculate the total ROI based on the precision
prec.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# Get precision and total ROI
prec = ____(y_test, ____, average = 'weighted')
r = 0.2
cost = 0.05
roi = ____ * r / cost
# Get AUC
roc_auc = roc_auc_score(y_test, y_score[:, 1])
print("Total ROI: %s, Precision: %s, AUC of ROC curve: %s" %(
roi, prec, roc_auc))