整理预测后验分布
现在来绘制一些新的预测结果。本练习中,我们将预测一首刚发布、song_age 为 0 的歌曲会有多受欢迎。我们仍然从 song_age 和 artist_name 来预测 popularity。new_predictions 对象已创建,包含了针对 Adele、Taylor Swift 和 Beyoncé 的新歌预测分数的分布。
本练习是课程的一部分
使用 rstanarm 进行贝叶斯回归建模
练习说明
- 打印
new_predictions的前 10 次迭代的预测分数。 - 将
new_predictions转换为一个数据框,并将其列命名为 "Adele"、"Taylor Swift" 和 "Beyoncé"。 - 将数据整理为长格式,只保留两列:
artist_name和predict。 - 打印新整理的
plot_posterior数据框的前六行。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# View new data predictions
___[___:___, ]
# Convert to data frame and rename variables
new_predictions <- ___(new_predictions)
___(___) <- c("___", "___", "___")
# Create tidy data structure
plot_posterior <- ___(new_predictions, key = "artist_name", value = "predict")
# Print formated data
___(plot_posterior)