Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def log_prob(model, words, class_name):
- logp = math.log(model["class_counts"][class_name] / model["total_docs"])
- V = len(model["vocab"])
- a = model["alpha"]
- for word in words:
- wc = model["word_counts"][class_name].get(word, 0)
- logp += math.log((wc + a) / (model["total_words"][class_name] + a * V))
- return logp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement