開始使用免費開始

樣本外效能

樣本內效能能告訴你模型在擬合其所見資料時的表現如何。對於預測模型,也很重要的一點是檢查模型在新的、未見過的資料上的表現,也就是「樣本外」效能。

在這個練習中,你將使用 MAE(平均絕對誤差)來檢查模型在測試集預測上的表現。

你的工作區已再次預先載入了你在前面練習中建立並使用過的 model

本練習屬於課程

R 的樹狀模型機器學習

檢視課程

練習說明

  • 使用 model 預測樣本外的 final_grade,並用 bind_cols() 將你的預測加入 chocolate_test
  • 使用 yardstick 的函式計算平均絕對誤差。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Predict ratings on test set and add true grades
test_enriched <- predict(__, new_data = ___) %>%
    bind_cols(___)
    
# Compute the mean absolute error using one single function
___(___,
    ___,
    ___)
編輯並執行程式碼