将下采样后的预测概率转换为分类中的实际概率(使用 mlr)

Convert predicted probabilities after downsampling to actual probabilities in classification (using mlr)

如果我在不平衡的二进制目标变量的情况下使用欠采样来训练模型,则预测方法会在平衡数据集的假设下计算概率。如何将这些概率转换为不平衡数据的实际概率?转换 argument/function 是在 mlr 包还是其他包中实现的?例如:

a <- data.frame(y=factor(sample(0:1, prob = c(0.1,0.9), replace=T, size=100)))
a$x <- as.numeric(a$y)+rnorm(n=100, sd=1)
task <- makeClassifTask(data=a, target="y", positive="0")
learner <- makeLearner("classif.binomial", predict.type="prob")
learner <- makeUndersampleWrapper(learner, usw.rate = 0.1, usw.cl = "1")
model <- train(learner, task, subset = 1:50)
pred <- predict(model, task, subset = 51:100)
head(pred$data)

[Dal Pozzolo et al., 2015] 提出了一种非常简单但功能强大的方法。

Paper Title: "Calibrating Probability with Undersampling for Unbalanced Classification" Andrea Dal Pozzolo , Olivier Caelen† , Reid A. Johnson , Gianluca Bontempi

它专门用于解决下采样情况下的校准问题(即将 classifier 的预测概率转换为不平衡情况下的实际概率)。

您只需使用以下公式更正您的预测概率 p_s:

   p = beta * p_s / ((beta-1) * p_s + 1)

其中 beta 是欠采样后多数 class 个实例与原始训练集中多数 class 个实例的比率。

其他方法 已经提出了其他没有特别关注下采样偏差的方法。其中最受欢迎的有:

它们都在 R 中实现