Skip to content
DeepForgeby svx
All problems
EasyProbabilitypr-300

EM Mixture Weight Update

Problem

In the M-step of EM, each mixture weight becomes the average responsibility of its component across the data set: (1 / n) times the sum over points of responsibilities[n][k]. Return the list of updated weights, or an empty list for inconsistent shapes.

Hint

Average the responsibility columns over the data points.

Test cases

case 1
in: [[[0.9,0.1],[0.8,0.2],[0.2,0.8],[0.1,0.9]]]
expected: [0.5,0.5]
case 2
in: [[[0.6,0.3,0.1],[0.2,0.5,0.3]]]
expected: [0.4,0.4,0.2]
case 3
in: [[[1],[1]]]
expected: [1]
case 4
in: [[]]
expected: []
case 5
in: [[[1,0],[0.5,0.5]]]
expected: [0.75,0.25]
Starter codePython
def em_mixture_weight_update(responsibilities):
    # Your code here
    pass

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