Skip to content
DeepForgeby svx
All problems
EasyTime Seriests-181

Geometric Mean Ratios

Problem

Aggregate forecast accuracy multiplicatively. Compute the ratio forecast/actual for every point with a nonzero actual, then return the geometric mean of those ratios: the product raised to the power 1/k.

Return 0.0 when there are no usable ratios.

Hint

A value of 1.0 means the forecast is right on average in relative terms.

Test cases

case 1
in: [[100,200],[110,190]]
expected: 1.0222524150130436
case 2
in: [[50],[55]]
expected: 1.1
case 3
in: [[10,10],[10,10]]
expected: 1
case 4
in: [[4,8],[5,6]]
expected: 0.9682458365518543
Starter codePython
def geometric_mean_ratios(actual, forecast):
    # Your code here
    pass

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