แบ่งข้อมูล
มี dataframe ชื่อ df_examples ที่มีคอลัมน์ดังนี้: endword (string), features (vector), outvec (vector) และ label (int) ในแบบฝึกหัดนี้จะแบ่งข้อมูลออกเป็นชุด training และชุด testing เพื่อใช้ฝึกและทดสอบตัวจำแนก
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Introduction to Spark SQL in Python
คำแนะนำการฝึกหัด
- แบ่งข้อมูลตัวอย่างออกเป็นชุด train และ test ในสัดส่วน 80/20
- แสดงจำนวนตัวอย่างในชุด training
- แสดงจำนวนตัวอย่างในชุด testing
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Split the examples into train and test, use 80/20 split
df_trainset, df_testset = df_examples.____((____), 42)
# Print the number of training examples
print("Number training: ", ____.____)
# Print the number of test examples
print("Number test: ", ____.____)