Skip to content
DeepForgeby svx
All problems
MediumStatisticsst-266

Stratified Eval Weights

Problem

Return the sample-size-weighted average of per-stratum accuracies: sum(acc_i * size_i) / sum(size_i). Return 0.0 when the inputs are empty, have different lengths, or the total size is zero.

Test cases

case 1
in: [[0.8,0.5],[100,100]]
expected: 0.65
case 2
in: [[0.9],[0]]
expected: 0
case 3
in: [[],[]]
expected: 0
case 4
in: [[0.6,0.7,0.8],[10,20,70]]
expected: 0.76
Starter codePython
def stratified_accuracy(accs, sizes):
    # Your code here
    pass

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