When calculating prob, I’ve called prob_word_given_class and used word, cls, word_frequency = word_frequency, class_frequency = class_frequency.
However, I’m not matching the expected results (I’m getting 0.07450628366247755 and 0.0328719723183391) and failing the unit test. Not sure where I am going wrong?
Make sure that word_frequency represents the count of the specific word in the given class and that class_frequency represents the total count of all words in that class. Also, when calculating the probability, apply Laplace smoothing (if requested) by using the formula: \frac{(\text{count}(\text{word in class}) + 1)}{(\text{count}(\text{all words in class}) + \text{vocab size})}.
Double-check that your vocabulary size is correctly determined as the total number of unique words across all classes. Check these values by printing them!
If you still need further assistance, feel free to send your code in PV (Click on Profile → Message) so we can check it together.