新歌的熱門程度
Beyoncé 最新的專輯《Lemonade》不在我們的 songs 資料集中。讓我們來預測這張專輯上一首歌的熱門程度。專輯《Lemonade》在本資料集建立前 663 天發行。你在上一個練習建立的 stan_model 物件已載入到你的環境中。
本練習屬於課程
使用 rstanarm 的貝葉斯迴歸建模
練習說明
- 建立一個待預測的新資料資料框,包含
song_age與artist_name兩個變數。 - 建立《Lemonade》上一首歌曲之預測熱門程度的後驗分佈。
- 列印後驗分佈中前 10 次抽樣的預測熱門程度。
- 列印該 1 筆新觀測值之後驗預測摘要。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Create data frame of new data
predict_data <- data.frame(___ = ___, ___ = "Beyoncé")
# Create posterior predictions for Lemonade album
new_predictions <- ___(stan_model, ___ = predict_data)
# Print first 10 predictions for the new data
___[___:___,]
# Print a summary of the posterior distribution of predicted popularity
___(new_predictions[, ___])