ComeçarComece de graça

Classifier comparison

The ROI framework can be run across different classifiers to see how higher precision and recall lead to higher ROI values. Note that the baseline classifier you created would have a total return and cost of 0 since both the true positives tp and false positives fp will be 0 by design. In this exercise, you will use the ROI framework to compare a logistic regression and decision tree classifier.

X_train, y_train, X_test, y_test are available in your workspace along with pandas as pd, numpy as np. LogisticRegression() from sklearn.linear_model is available as well.

Este exercício faz parte do curso

Predicting CTR with Machine Learning in Python

Ver curso

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# 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))
Editar e executar o código