為突發狀況做好準備
Brett 追蹤自己 13 週的所在位置期間,週末從未進辦公室。因此,P(office and weekend) 的聯合機率為 0。
請探討這對於未來預測 Brett 是否可能在週末去上班的機率有何影響。此外,你也可以觀察使用 Laplace 校正如何讓這類突發情況仍保留一點點發生的可能性。
你可以使用模型 locmodel 與資料框 weekend_afternoon。naivebayes 套件也已預先載入。
本練習屬於課程
R 監督式學習:分類
練習說明
- 使用
locmodel和predict()函式,對週末下午的情境輸出預測機率。記得設定type參數。 - 建立一個新的 Naive Bayes 模型,將 Laplace 平滑參數設為
1,也就是在呼叫naive_bayes()時設定laplace參數。將結果儲存為locmodel2。 - 使用
predict()套用在新模型上,比較新的預測機率差異。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Observe the predicted probabilities for a weekend afternoon
# Build a new model using the Laplace correction
locmodel2 <- ___
# Observe the new predicted probabilities for a weekend afternoon