模型效能指標
在建模流程中,評估模型結果是很重要的一步。應該在測試資料集上進行模型評估,才能了解模型在新資料集上的泛化能力有多好。
在前一個練習中,你已經訓練了一個線性迴歸模型,用 home_age 和 sqft_living 作為自變數來預測 selling_price。接著,你使用訓練好的模型在 home_test 資料上建立了 home_test_results 這個 tibble。
在本練習中,你會使用 home_test_results 計算 RMSE 和 R squared 指標。
home_test_results tibble 已載入到你的工作階段。
本練習屬於課程
在 R 中使用 tidymodels 建立模型
練習說明
- 先執行前兩行會列印
home_test_results的程式碼。這個 tibble 包含home_test資料集中實際與預測的房屋售價。 - 使用
home_test_results計算 RMSE 和 R squared 指標。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Print home_test_results
home_test_results
# Calculate the RMSE metric
home_test_results %>%
___(___, ___)
# Calculate the R squared metric
home_test_results %>%
___(___, ___)