模型性能指标
评估模型结果是建模流程中的重要步骤。应在测试数据集上进行模型评估,以了解模型在新数据集上的泛化能力。
在上一个练习中,您训练了一个线性回归模型,用 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 %>%
___(___, ___)