Generalized additive models for calibration

六眼飞鱼酱① 提交于 2019-12-25 03:41:23

问题


I work on calibration of probabilities. I'm using a probability mapping approach called generalized additive models.

The algorithm I wrote is:

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)
}

The package I'm using is mgcv.

  1. x - prediction on train dataset
  2. y - prediction on test dataset
  3. datax - traindata
  4. datay - testdata

Problems:

  1. The output values are not between 0 and 1
  2. I get the following warning message:

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

回答1:


The warning is telling you that predict.gam doesn't recognize the value you passed to the type parameter. Since it didn't understand, it decided to use the default value of type, which is "terms".

Note that predict.gam with type="terms" returns information about the model terms, not probabilties. Hence the output values are not between 0 and 1.

For more information about mgcv::predict.gam, take a look here.



来源:https://stackoverflow.com/questions/29954519/generalized-additive-models-for-calibration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!