เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

การใช้ชุดตัวแปรที่แตกต่างกัน

การเพิ่มตัวแปรและความซับซ้อนให้กับโมเดล Logistic Regression ไม่ได้หมายความว่าโมเดลจะแม่นยำขึ้นเสมอไป ในแบบฝึกหัดนี้ ลองตรวจสอบว่าการเพิ่มตัวแปร 3 ตัวเข้าไปในโมเดลจะทำให้ผลลัพธ์ดีขึ้นหรือไม่

variables_1 และ variables_2 พร้อมใช้งานในสภาพแวดล้อมของคุณแล้ว สามารถพิมพ์ไปที่ console เพื่อดูรายละเอียดได้

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

การวิเคราะห์เชิงพยากรณ์เบื้องต้นด้วย Python

ดูคอร์ส

คำแนะนำการฝึกหัด

  • Fit โมเดล logreg โดยใช้ variables_2 ซึ่งมีตัวแปรเพิ่มขึ้นมา 3 ตัวเมื่อเทียบกับ variables_1
  • สร้างการพยากรณ์สำหรับโมเดลนี้
  • คำนวณค่า AUC ของโมเดลนี้

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

# Create appropriate DataFrames
X_1 = basetable[variables_1]
X_2 = basetable[variables_2]
y = basetable[["target"]]

# Create the logistic regression model
logreg = linear_model.LogisticRegression()

# Make predictions using the first set of variables and assign the AUC to auc_1
logreg.fit(X_1, y)
predictions_1 = logreg.predict_proba(X_1)[:,1]
auc_1 = roc_auc_score(y, predictions_1)

# Make predictions using the second set of variables and assign the AUC to auc_2
logreg.____(____, ____)
predictions_2 = ____.____(____)[____,____]
auc_2 = ____(____, ____)

# Print auc_1 and auc_2
print(round(auc_1,2))
print(round(auc_2,2))
แก้ไขและรันโค้ด