用于校准的广义加性模型

Generalized additive models for calibration

我从事概率校准工作。我正在使用一种称为 generalized additive models.

的概率映射方法

我写的算法是:

probMapping = function(x, y, datax, datay) {

    if(length(x) < length(y))stop("train smaller than test")
    if(length(datax) < length(datay))stop("train smaller than test")

    datax$prob = x # trainset: data and raw probabilities
    datay$prob = y # testset: data and raw probabilities

    prob_map = gam(Target ~ prob, data = datax, familiy = binomial, trace = TRUE)
    prob_map_prob = predict(prob_map, newdata = datay, type = "prob")

  # return(str(datax))
  return(prob_map_prob)
}

我使用的包是mgcv

  1. x - 在 train 数据集上的预测
  2. y - 在 test 数据集上的预测
  3. datax - traindata
  4. 数据日 - testdata

问题:

  1. 输出值不在 0 和 1 之间
  2. 我收到以下警告消息:

    In predict.gam(prob_map, newdata = datay, type = "prob") :
    Unknown type, reset to terms.
    

警告告诉您 predict.gam 无法识别您传递给 type 参数的值。由于看不懂,所以决定使用type的默认值,即"terms".

请注意 predict.gamtype="terms" returns 有关模型项的信息, 不是 概率。因此输出值不在 0 和 1 之间。

有关 mgcv::predict.gam 的更多信息,请查看 here