การพยากรณ์ CTR ด้วย Machine Learning ใน Python
Kevin Huo
Instructor

| is_student | loan | |
|---|---|---|
| middle_aged | 1 | |
| youth | no | 0 |
| youth | yes | 1 |
clf = DecisionTreeClassifier()เช่นเดียวกับ logistic regression ใช้ clf.fit(X_train, y_train) สำหรับข้อมูล training และ clf.predict(X_test) สำหรับ label testing:
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]])
ตัวอย่างการแบ่งข้อมูล training และ testing แบบสุ่ม โดย testing คิดเป็น 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(): อาร์เรย์ test และ scoreroc_auc = auc(fpr, tpr)
อินพุตของ auc(): อาร์เรย์ false-positive และ true-positive
หากโมเดลแม่นยำแต่ CTR ต่ำ ควรพิจารณาใหม่ว่าสารของโฆษณาถูกนำเสนออย่างไรและกำหนดเป้าหมายกลุ่มผู้ชมใด
การพยากรณ์ CTR ด้วย Machine Learning ใน Python