A simple Naive Bayes location model
The previous exercises showed that the probability that Brett is at work or at home at 9am is highly dependent on whether it is the weekend or a weekday.
To see this finding in action, use the where9am data frame to build a Naive Bayes model on the same data.
You can then use this model to predict the future: where does the model think that Brett will be at 9am on Thursday and at 9am on Saturday?
The data frame where9am is available in your workspace. This dataset contains information about Brett's location at 9am on different days.
Latihan ini adalah bagian dari kursus
Supervised Learning in R: Classification
Petunjuk latihan
- Load the
naivebayespackage. - Use
naive_bayes()with a formula likey ~ xto build a model oflocationas a function ofdaytype. - Forecast the Thursday 9am location using
predict()with thethursday9amobject as thenewdataargument. - Do the same for predicting the
saturday9amlocation.
Latihan interaktif praktis
Cobalah latihan ini dengan menyelesaikan kode contoh berikut.
# Load the naivebayes package
# Build the location prediction model
locmodel <- naive_bayes(___, data = ___)
# Predict Thursday's 9am location
predict(___, ___)
# Predict Saturdays's 9am location