Advertisement
gandalfbialy

Untitled

May 24th, 2025
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. def log_prob(model, words, class_name):
  2. logp = math.log(model["class_counts"][class_name] / model["total_docs"])
  3. V = len(model["vocab"])
  4. a = model["alpha"]
  5. for word in words:
  6. wc = model["word_counts"][class_name].get(word, 0)
  7. logp += math.log((wc + a) / (model["total_words"][class_name] + a * V))
  8. return logp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement