评估模型质量
现在该开始评估模型质量了。
在本练习中,您将比较基于 Ames 房价数据的交叉验证 XGBoost 模型的 RMSE 和 MAE。与之前的练习一样,所有必要的模块都已预加载,数据已存放在 DataFrame df 中。
本练习是课程的一部分
使用 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))