2015-04-29 27 views
0

我從事概率校準工作。我正在使用名爲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. ý - 預測上test數據集
  3. DATAX - traindata
  4. DATAY - testdata

問題:

  1. 輸出值不是0和1之間
  2. 我得到以下警告消息:

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

回答

0

該警告是告訴你,predict.gam不承認你傳遞給type參數的值。由於不理解,決定使用默認值type,即"terms"

注意predict.gamtype="terms"返回有關模型項信息, probabilties。因此,輸出值不在0和1之間。

有關mgcv::predict.gam的詳細信息,請參閱here

+0

嘿亞歷克斯,非常感謝你的回答!我已經瞭解到兩點:i)類型必須是「迴應」,ii)在擬閤中存在錯誤,我寫了「家庭」 - 必須是「家庭」。我爲此感到抱歉。亞歷克斯,請你也請評論:http://stackoverflow.com/questions/29948919/calibration-of-the-posterior-probabilities-我已經嘗試過提供的答案,但結果仍然不在0和1之間 – user4847048