Examining "raw" probabilities
The naivebayes package offers several ways to peek inside a Naive Bayes model.
Typing the name of the model object provides the a priori (overall) and conditional probabilities of each of the model's predictors. If one were so inclined, you might use these for calculating posterior (predicted) probabilities by hand.
Alternatively, R will compute the posterior probabilities for you if the type = "prob" parameter is supplied to the predict() function.
Using these methods, examine how the model's predicted 9am location probability varies from day-to-day. The model locmodel that you fit in the previous exercise is available for you to use, and the naivebayes package has been pre-loaded.
Deze oefening maakt deel uit van de cursus
Supervised Learning in R: Classification
Oefeninstructies
- Print the
locmodelobject to the console to view the computed a priori and conditional probabilities. - Use the
predict()function similarly to the previous exercise, but withtype = "prob"to see the predicted probabilities for Thursday at 9am. - Compare these to the predicted probabilities for Saturday at 9am.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# Examine the location prediction model
# Obtain the predicted probabilities for Thursday at 9am
predict(___, ___ , type = ___)
# Obtain the predicted probabilities for Saturday at 9am