Skip to content
DeepForgeby svx
All problems
MediumTime Seriests-197

Forecastability Score

Problem

Score how forecastable a series is as 1 - Var(differences) / Var(levels), using population variances. A perfectly linear or smooth series scores near 1; white noise scores near 0. Clamp the result to [0, 1].

Return 0.0 when the series has fewer than two points or zero level variance.

Hint

Smooth, drifting series are easier to extrapolate than jumpy ones.

Test cases

case 1
in: [[1,2,3,4]]
expected: 1
case 2
in: [[5,5,5]]
expected: 0
case 3
in: [[1,-1,1,-1,1]]
expected: 0
case 4
in: [[1,1,2,2,3,3]]
expected: 0.6399999999999999
Starter codePython
def forecastability_score(series):
    # Your code here
    pass

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