All problems
Add K Smoothed Log Probability
Problem
Add-k smoothing estimates a probability as (count + k) / (total + k * vocab_size).
Given the count, the total number of events, k, and the vocabulary size, return the natural log of the smoothed probability.
Hint
Smooth the numerator and denominator before taking the log.
Test cases
case 1
in: [5,100,1,50]
expected: -3.2188758248682006
case 2
in: [0,10,1,5]
expected: -2.70805020110221
case 3
in: [30,1000,0.1,100]
expected: -3.513180438080475
Starter codePython
def add_k_smoothed_log_probability(count, total, k, vocab_size):
# Your code here
pass3 test cases · run your code against them in the editor