对于可以使用的计数数据,有几个适当的和严格适当的评分规则。计分规则是引入的惩罚其中P为预测分布,y为观察值。它们具有许多理想的属性,首先,最重要的是,更接近真实概率的预测将始终受到较少的惩罚,并且存在(唯一)最佳预测,而当预测概率与真实概率一致时就是一个预测。因此,将s (y ,P )的期望值最小化意味着报告真实概率。另请参阅Wikipedia。s(y,P)Pys(y,P)
通常,将所有预测值的平均值作为
S=1n∑ni=1s(y(i),P(i))
采取哪个规则取决于您的目标,但是当每个规则都可以使用时,我将给出一个粗略的描述。
f(y)Pr(Y=y)F(y)∑k0,1,…,∞Iμσ
严格正确的评分规则
- 石蜡分数:小号(ÿ,P)= − 2 f(y)+ ∑ķF2(k) (stable for size imbalance in categorical predictors)
- Dawid-Sebastiani score: s(y,P)=(y−μσ)2+2logσ (good for general predictive model choice; stable for size imbalance in categorical predictors)
- Deviance score: s(y,P)=−2logf(y)+gy (gy is a normalization
term that only depends on y, in Poisson models it is usually taken
as the saturated deviance; good for use with estimates from an ML framework)
- Logarithmic score: s(y,P)=−logf(y) (very easily calculated; stable for size imbalance in categorical predictors)
- Ranked probability score: s(y,P)=∑k{F(k)−I(y≤k)}2 (good for contrasting different predictions of very high counts; susceptible to size imbalance in categorical predictors)
- Spherical score: s(y,P)=f(y)∑kf2(k)√ (stable for size imbalance in categorical predictors)
Other scoring rules (not so proper but often used)
- Absolute error score: s(y,P)=|y−μ| (not proper)
- Squared error score: s(y,P)=(y−μ)2 (not strictly proper; susceptible to outliers; susceptible to size imbalance in categorical predictors)
- Pearson normalized squared error score: s(y,P)=(y−μσ)2 (not strictly proper; susceptible to outliers; can be used for checking if model checking if the averaged score is very different from 1; stable for size imbalance in categorical predictors)
Example R code for the strictly proper rules:
library(vcdExtra)
m1 <- glm(Freq ~ mental, family=poisson, data=Mental)
# scores for the first observation
mu <- predict(m1, type="response")[1]
x <- Mental$Freq[1]
# logarithmic (equivalent to deviance score up to a constant)
-log(dpois(x, lambda=mu))
# quadratic (brier)
-2*dpois(x,lambda=mu) + sapply(mu, function(x){ sum(dpois(1:1000,lambda=x)^2) })
# spherical
- dpois(x,mu) / sqrt(sapply(mu, function(x){ sum(dpois(1:1000,lambda=x)^2) }))
# ranked probability score
sum(ppois((-1):(x-1), mu)^2) + sum((ppois(x:10000,mu)-1)^2)
# Dawid Sebastiani
(x-mu)^2/mu + log(mu)