พยากรณ์ข้อมูลทดสอบ
โมเดล logistic ที่ฝึกแล้วชื่อ df_fitted พร้อมใช้งานแล้ว มี DataFrame ชื่อ df_testset ที่บรรจุข้อมูลทดสอบสำหรับโมเดลนี้ และมีตัวแปร fields ที่เก็บรายการ ['prediction', 'label', 'endword', 'doc', 'probability'] ไว้สำหรับระบุว่าจะแสดงฟิลด์การพยากรณ์ใดบ้าง
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Introduction to Spark SQL in Python
คำแนะนำการฝึกหัด
- นำโมเดลไปใช้กับข้อมูลใน
df_testset - แสดงข้อความ "incorrect" หากผลการพยากรณ์ไม่ตรงกับ label
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Apply the model to the test data
predictions = df_fitted.____(____).select(fields)
# Print incorrect if prediction does not match label
for x in predictions.take(8):
print()
if x.label != int(x.____):
print("INCORRECT ==> ")
for y in fields:
print(y,":", x[y])