ci.eval {gcl}R Documentation

Function that evaluates the cindex of a classifier function on a data frame

Description

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.

Usage

ci.eval(cf, df, ...)

Arguments

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.

Details

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.

Value

The c-index.

Author(s)

Staal A. Vinterbo staal@dsg.harvard.edu

References

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.

See Also

acc.eval, cindex

Examples

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

[Package gcl version 1.06.5 Index]