区間予測の評価指標

区間予測の評価指標#

D2 pinball score#

D2は決定係数R2の一般化

D2(y,y^)=1dev(y,y^)dev(y,ynull)

ここでynullは切片のみのモデルの最適解(例:二乗誤差ならyの平均値、絶対誤差ならyの中央値、pinball lossならyの指定されたquantile)

このD2

dev(y,y^)=pinball(y,y^)={(τ1)(yy^) if (yy^)0τ(yy^) if (yy^)>0

を代入したものがD2 pinball score

(参考:3.3. Metrics and scoring: quantifying the quality of predictions — scikit-learn 1.4.1 documentation

interval score#

Gneiting, T., & Raftery, A. E. (2007). Strictly proper scoring rules, prediction, and estimation. Journal of the American statistical Association, 102(477), 359-378.

(1α)×100%予測区間を[l,u]=[α2,1α2] quantileで構築したとする。

interval scoreは真の値をxとして

Sα(l,u;x)=(ul)+2α(lx)1{x<l}+2α(xu)1{x>u}

となる。(スコアが小さいほうが良いモデルを意味する)

import numpy as np

def interval_score(l, u, x, alpha):
    return (u - l) + (2 / alpha) * (l - x) * (x < l) + (2 / alpha) * (x - u) * (x > u)

alpha = 0.05
true_values = 5

# 予測1
lower, upper = (1, 10)
s1 = interval_score(lower, upper, true_values, alpha)
# 予測2
lower, upper = (4, 6)
s2 = interval_score(lower, upper, true_values, alpha)
print(f"{s1=}, {s2=}")
s1=9.0, s2=2.0

Calibration#