All problems
HMM Emission Probability
Problem
Return the emission probability P(symbol | state) from a nested count dictionary mapping each state to symbol counts.
Divide the symbol count by the total count for that state. Return 0.0 when the state or symbol is missing, or when the state has no counts.
Hint
Normalize within the requested state only.
Test cases
case 1
in: ["A","x",{"A":{"x":3,"y":1},"B":{"x":1}}]
expected: 0.75
case 2
in: ["B","z",{"A":{"x":1}}]
expected: 0
case 3
in: ["C","x",{}]
expected: 0
case 4
in: ["A","x",{"A":{}}]
expected: 0
Starter codePython
def hmm_emission_prob(state, symbol, counts):
# Your code here
pass4 test cases · run your code against them in the editor