# Question on Naive Bayes - have a different solution

In the session of “Naive Bayes for Sentiment Analysis”, I have a different solution from the code showed. The nominators for Naive Bayes equals probablity of y multiplying probablility of each x given y. In this case,
the probability of “run" given “was tired” = 3 / 5 (5 of 7 are “was tired”), while the solution given is 3 /7, which i believe is the prbabability when both “run” and “was tired” happen.
Below is my code. Can anybody confirm whether my understanding is right or wrong?
https://app.dataquest.io/m/27/naive-bayes-for-sentiment-analysis/2/overview-of-naive-bayes

Sample code given:

``````    def calc_ran_probability_given_y(ran_label, y_label, days):
return len([d for d in days if d == y_label and d == ran_label]) / len(days)

def calc_woke_early_probability_given_y(woke_label, y_label, days):
return len([d for d in days if d == y_label and d == woke_label]) / len(days)
``````

My Code:

``````    def calc_ran_probability_given_y(ran_label, y_label, days):
return len([d for d in days if d == y_label and d == ran_label]) / len([d for d in days if d==y_label])

def calc_woke_early_probability_given_y(woke_label, y_label, days):
return len([d for d in days if d == y_label and d == woke_label]) / len([d for d in days if d==y_label])``````