Question
The Naive Bayes model assumes that all features are conditionally independent given the class label. For our purposes, this means that the probability of seeing
The Naive Bayes model assumes that all features are conditionally independent given the class label. For our purposes, this means that the probability of seeing a particular word in a document with class label $y$ is independent of the rest of the words in that document. Implement the `p_word_given_label` function in the [Naive Bayes Block](#Naive-Bayes-Block). This function calculates P (w|y) (i.e., the probability of seeing word w in a document given the label of that document is y). Use your `p_word_given_label` function to compute the probability of seeing the word amazing given each sentiment label. Repeat the computation for the word dull. print ("P('amazing'|pos):", nb.p_word_given_label("amazing", POS_LABEL)) print ("P('amazing'|neg):", nb.p_word_given_label("amazing", NEG_LABEL)) print ("P('dull'|pos):", nb.p_word_given_label("dull", POS_LABEL)) print ("P('dull'|neg):", nb.p_word_given_label("dull", NEG_LABEL)) Which word has a higher probability, given the positive class? Which word has a higher probability, given the negative class? Is this behavior expected?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started