การประเมินคุณภาพโมเดล
ถึงเวลาเริ่มประเมินคุณภาพโมเดลกันแล้ว
ในแบบฝึกหัดนี้ จะได้เปรียบเทียบค่า RMSE และ MAE ของโมเดล XGBoost ที่ผ่านการ cross-validation บนชุดข้อมูลราคาบ้าน Ames โดยโมดูลที่จำเป็นทั้งหมดถูกโหลดไว้ล่วงหน้าแล้ว และข้อมูลพร้อมใช้งานใน DataFrame df
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Extreme Gradient Boosting with XGBoost
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Create the DMatrix: housing_dmatrix
housing_dmatrix = xgb.DMatrix(data=X, label=y)
# Create the parameter dictionary: params
params = {"objective":"reg:squarederror", "max_depth":4}
# Perform cross-validation: cv_results
cv_results = ____(dtrain=____, params=____, nfold=____, num_boost_round=____, metrics=____, as_pandas=True, seed=123)
# Print cv_results
print(cv_results)
# Extract and print final boosting round metric
print((cv_results["____"]).tail(1))