后验概率的校准 [英] calibration of the posterior probabilities

查看:215
本文介绍了后验概率的校准的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我工作的概率校准。我用的是定标方法,称为重新缩放算法 - 源的 http://lem.cnrs.fr/Portals/2/actus/DP_201106.pdf (第7页)。

currently i work on calibration of probability. i use the calibration approach, called rescaling algorithm - the source http://lem.cnrs.fr/Portals/2/actus/DP_201106.pdf (page 7).

算法我写的是:

rescaling_fun = function(x, y, z) {

    P_korg  = z # yhat_test_prob$BAD

    P_k_C1  = sum(as.numeric(y) - 1)/length(y) # testset$BAD
    P_kt_C1 = sum(as.numeric(x) - 1)/length(x) # trainset$BAD
    P_k_C0  = sum(abs(as.numeric(y) - 2))/length(y)
    P_kt_C0 = sum(abs(as.numeric(x) - 2))/length(x)

    P_new <- ((P_k_C1/P_kt_C1) * P_korg)/((P_k_C0/P_k_C0) * (1 - P_korg) + (P_k_C0/P_k_C1) * (P_korg))

  return(P_new)
}

的输入值是:

the input values are:

1. x - train_set$BAD (actuals of `train set`)
2. y - test_set$BAD (actuals of `test set`)
3. z - yhat_test_prob$BAD (prediction on `test set`)

问题 - 结果值不是在 0 1 的范围内。能否请你帮忙解决这个问题?

the problem - the result values are not within range of 0 and 1. Could you please help to solve the problem?

推荐答案

您的公式来获得probs(P_k_C1 ... <$ C C $>)需要进行修改。例如,根据纸张,y是二元变量(0,1)和公式是总和(Y - 1)/长度(y)的这是最有可能的为负 - 其转换y值是-​​1或0,接着加入它们。我认为它应该是(SUM(Y)-1)/长度(Y)。下面是一个例子。

Your formulas to obtain probs (P_k_C1 ...) need to be modified. For example, according to the paper, y is a binary variable (0, 1) and the formula is sum(y - 1)/length(y) which is most likely to be negative - it converts y values to be -1 or 0, followed by adding them. I consider it should be (sum(y)-1)/length(y). Below is an example.

set.seed(1237)
y <- sample(0:1, 10, replace = T)
y
[1] 0 1 0 0 0 1 1 0 1 1
# it must be negative as it is sum(y - 1) - y is 0 or 1
sum(as.numeric(y) - 1)/length(y)
[1] -0.5
# modification 
(sum(as.numeric(y)) - 1)/length(y)
[1] 0.4

这篇关于后验概率的校准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆