Skip to content
DeepForgeby svx
All problems
MediumNLPnlp-168

Emotion Probability Vector

Problem

Convert emotion counts to a Laplace-smoothed probability vector: (count + 1) / (total + number of emotions).

Every count receives the same additive smoothing, so the vector always sums to 1. Return an empty list for empty input.

Hint

Add one to every count and to the denominator once per emotion class.

Test cases

case 1
in: [[1,1,1,1]]
expected: [0.25,0.25,0.25,0.25]
case 2
in: [[0,0]]
expected: [0.5,0.5]
case 3
in: [[3,0]]
expected: [0.8,0.2]
case 4
in: [[]]
expected: []
case 5
in: [[5]]
expected: [1]
Starter codePython
def emotion_probability_vector(counts):
    # Your code here
    pass

5 test cases · run your code against them in the editor