擬合線性迴歸模型
parsnip 套件在 R 中提供了一致的模型擬合語法。
使用 parsnip,你可以輕鬆透過 R 生態系中各種套件(也稱為 engine)來定義模型。
在這個練習裡,你會定義一個 parsnip 的線性迴歸物件,並以 home_sales 資料中的 home_age 與 sqft_living 作為解釋變數,訓練模型來預測 selling_price。
你在前一個單元建立的 home_training 與 home_test tibble 已經載入到本次工作階段。
本練習屬於課程
在 R 中使用 tidymodels 建立模型
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Initialize a linear regression object, linear_model
linear_model <- ___ %>%
# Set the model engine
___ %>%
# Set the model mode
___