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

AdaBoost regression แบบ Tree-based

โมเดล AdaBoost มักใช้ decision tree เป็น base estimator ลองทดสอบแนวทางนี้ดูว่าประสิทธิภาพของโมเดลจะดีขึ้นอีกหรือไม่

จะใช้ estimator จำนวน 12 ตัวเหมือนเดิม เพื่อให้การเปรียบเทียบเป็นธรรม โดยไม่จำเป็นต้องสร้าง decision tree แยกต่างหาก เนื่องจากเป็น base estimator ค่าเริ่มต้นอยู่แล้ว

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

Ensemble Methods ใน Python

ดูคอร์ส

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

  • สร้างและ fit AdaBoostRegressor โดยใช้ estimator จำนวน 12 ตัว โดยไม่ต้องระบุ base estimator
  • คำนวณค่าพยากรณ์บนชุดทดสอบ

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

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

# Build and fit a tree-based AdaBoost regressor
reg_ada = ____(____, random_state=500)
reg_ada.fit(X_train, y_train)

# Calculate the predictions on the test set
pred = ____

# Evaluate the performance using the RMSE
rmse = np.sqrt(mean_squared_error(y_test, pred))
print('RMSE: {:.3f}'.format(rmse))
แก้ไขและรันโค้ด