PythonでMachine Learningを使ってCTRを予測する
Kevin Huo
Instructor

| is_student | loan | |
|---|---|---|
| middle_aged | 1 | |
| youth | no | 0 |
| youth | yes | 1 |
clf = DecisionTreeClassifier()ロジスティック回帰同様、学習は clf.fit(X_train, y_train)、予測は clf.predict(X_test)
array([0, 1, 1, ..., 1, 0, 1])
確率出力は clf.predict_proba(X_test)
array([0.2, 0.8], [0.4, 0.6] ..., [0.1, 0.9] [0.3, 0.7]])
学習/評価データのランダム分割例(評価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() の入力: テストとスコア配列roc_auc = auc(fpr, tpr)
auc() の入力: 偽陽性率と真陽性率の配列
モデルが高精度でCTRが低い場合は、広告メッセージやターゲット設定を見直すとよいでしょう
PythonでMachine Learningを使ってCTRを予測する