多變量線性迴歸(第 2 部分)
現在你要使用上一個練習中擬合的血壓模型 bloodpressure_model 來進行預測。
你也會用圖形將預測值與實際結果做比較。已經載入 ggplot2。回想一下,繪圖指令的形式為:
ggplot(dframe, aes(x = pred, y = outcome)) +
geom_point() +
geom_abline(color = "blue")
bloodpressure 和 bloodpressure_model 已可供你使用。
本練習屬於課程
R 中的監督式學習:回歸
練習說明
- 使用
predict()對bloodpressure資料集的血壓進行預測。將預測值指定到欄位prediction。 - 以圖形方式將預測值與實際血壓比較。把預測值放在 x 軸。結果與「完美預測」那條線有多接近?
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# bloodpressure is available
summary(bloodpressure)
# bloodpressure_model is available
bloodpressure_model
# Predict blood pressure using bloodpressure_model: prediction
bloodpressure$prediction <- ___
# Plot the results
___ +
___ +
geom_abline(color = "blue")