開始使用免費開始

擴增你的資料

glance() 的結果中,你已經看到,使用現有特徵所建立的線性模型擬合得不錯,調整後的 \(R^2\) 為 0.99augment() 函式可以把預測值附加回原始資料,幫助你探索這個擬合情形。

在這裡,你會利用這點,根據 year 特徵,將 life_expectancy 的預測值與原始值進行比較。

本練習屬於課程

Tidyverse 的 Machine Learning

檢視課程

練習說明

  • 使用 augment() 建立擴增後的資料框 algeria_fitted
  • year 為基準視覺化模型的擬合:將 life_expectancy 畫成散點,並將 .fitted 畫成線條。

動手互動練習

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

# Build the augmented data frame
algeria_fitted <- ___

# Compare the predicted values with the actual values of life expectancy
algeria_fitted %>% 
  ggplot(aes(x = ___)) +
  geom_point(aes(y = ___)) + 
  geom_line(aes(y = ___), color = "red")
編輯並執行程式碼