Prevedere il CTR con il Machine Learning in Python
Kevin Huo
Instructor

| is_student | loan | |
|---|---|---|
| middle_aged | 1 | |
| youth | no | 0 |
| youth | yes | 1 |
clf = DecisionTreeClassifier()Come per la regressione logistica: clf.fit(X_train, y_train) per il training e clf.predict(X_test) per le etichette di test:
array([0, 1, 1, ..., 1, 0, 1])
clf.predict_proba(X_test) per le probabilità:
array([0.2, 0.8], [0.4, 0.6] ..., [0.1, 0.9] [0.3, 0.7]])
Esempio di split casuale train/test, con test al 30%: train_test_split(X, y, test_size = .3, random_state = 0)

Y_score = clf.predict_proba(X_test)
fpr, tpr, thresholds = roc_curve(Y_test, Y_score[:, 1])
roc_curve(): array di test e scoreroc_auc = auc(fpr, tpr)
Input di auc(): array di false positive e true positive
Se il modello è accurato ma il CTR è basso, rivaluta messaggio dell’annuncio e target
Prevedere il CTR con il Machine Learning in Python