ci.eval {gcl} | R Documentation |
This function evaluates a classifier function on a data set. Returns the c-index, aka. the area under the receiver operating curve. Works only on binary outcomes.
ci.eval(cf, df, ...)
cf |
Classifier function, must accept df as an argument and
return a matrix with class labels as column names and entry (i,j)
containing the classifiers belief that case i is of class j. |
df |
Data set (frame), last column must be outcome and encoded as numeric |
... |
Not used. |
The c-index is related to the Wilcoxon rank sum statistic or Mann-Whitney U. It is equivalent to the area under the receiver operating curve and is an estimate the probability of the classifier ranking a randomly chosen positive example as more positive than a randomly chosen negative example.
The c-index.
Staal A. Vinterbo staal@dsg.harvard.edu
J.A. Hanley and B.J. McNeil. The meaning and use of the area under a receiver operating characteristic (ROC) curve. Radiology, 143:29-36, 1982.
## The function is currently defined as ## Not run: function (cf, df, ...) { clsv <- unlist(df[, ncol(df)]) clss <- unique(clsv) if (length(clss) != 2) stop("Cannot compute CI on non-binary outcomes. Aborting.\n", call. = F) clss <- sort(clss) cs <- cf(df, ...) if (is.null(cs)) return(NULL) csc <- colnames(cs) prev <- sum(clsv == clss[2])/length(clsv) csn <- t(apply(cs, 1, pnormalize, c(1 - prev, prev))) pred <- csn[, 2] act <- clsv == clss[2] return(cindex(pred, act)[1]) } ## End(Not run)