モデル品質の評価
ここからモデルの品質評価を始めます。
この演習では、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))