เทรนตัวจำแนกประเภท
dataframe df_trainset ที่สร้างไว้ในแบบฝึกหัดก่อนหน้าพร้อมใช้งานแล้ว ขั้นตอนนี้จะนำมาใช้เทรน Logistic Regression Classifier
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Introduction to Spark SQL in Python
คำแนะนำการฝึกหัด
- Import Logistic Regression Classifier
- สร้าง instance ของตัวจำแนกประเภท โดยกำหนดจำนวนรอบสูงสุดเป็น 100, พารามิเตอร์ regularization เป็น 0.4 และพารามิเตอร์ elastic net เป็น 0.0
- เทรนตัวจำแนกประเภทบนชุดข้อมูล trainset
- แสดงจำนวนรอบการเทรน
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Import the logistic regression classifier
from ____ import ____
# Instantiate logistic setting elasticnet to 0.0
logistic = ____(maxIter=100, regParam=0.4, ____=0.0)
# Train the logistic classifer on the trainset
df_fitted = ____.____(____)
# Print the number of training iterations
print("Training iterations: ", df_fitted.____.____)