Train_naive_bayes function

In the train_naive_bayes function, train_x is not really used. Or at least, I didn’t need to use it. Is there any reason to pass it into the function? Tnx.

UNQ_C2 GRADED FUNCTION: train_naive_bayes

def train_naive_bayes(freqs, train_x, train_y):

1 Like

That’s an interesting point that had not previously occurred to me. I checked my code and I didn’t reference train_x either. You do need train_y, of course. Maybe they just felt it would be weird to pass in just the labels for the tweets and not the tweets themselves. And of course there is also some redundancy in that the content of the freqs dictionary that is the first argument is also dependent on the tweet corpus. Maybe the more consistent way to implement this that doesn’t depend on previously created global state would be to omit the freqs argument: just pass train_x and train_y and then call count_tweets in the body of the train_naive_bayes function to compute freqs. That seems like a cleaner overall implementation. But they didn’t ask my opinion. :nerd_face: