常见预测模型

Lasso:https://cloud.tencent.com/developer/article/1621581

岭回归:https://cloud.tencent.com/developer/article/1664071

弹性网络(这个国外网站可以学着):https://daviddalpiaz.github.io/r4sl/elastic-net.html

performace函数


#函数performance

performance <- function(table, n=2){

  if(!all(dim(table) == c(2,2)))

    stop("Must be a 2 x 2 table")

  tn = table[1,1]

  fp = table[1,2]

  fn = table[2,1]

  tp = table[2,2]

  sensitivity = tp/(tp+fn)

  specificity = tn/(tn+fp)

  ppp = tp/(tp+fp)

  npp = tn/(tn+fn)

  hitrate = (tp+tn)/(tp+tn+fp+fn)

  result <- paste("Sensitivity = ", round(sensitivity, n) ,

                  "\nSpecificity = ", round(specificity, n),

                  "\nPositive Predictive Value = ", round(ppp, n),

                  "\nNegative Predictive Value = ", round(npp, n),

                  "\nAccuracy = ", round(hitrate, n), "\n", sep="")

  cat(result)

}
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容