col_auc {RcppColMetric} | R Documentation |
Column-wise area under ROC curve (AUC)
Description
Calculate area under the ROC curve (AUC) for every column of a matrix or data frame. For better performance, data frame is preferred.
Usage
col_auc(x, y, args = NULL)
Arguments
x |
Matrix or data frame. Rows contain samples and columns contain features/variables. |
y |
Factor of class labels for the data samples. A response vector with one label for each row/component of |
args |
|
Value
An output is a single matrix with the same number of columns as X and "n choose 2" ( n!/((n-2)! 2!) = n(n-1)/2 ) number of rows, where n is number of unique labels in y list. For example, if y contains only two unique class labels ( length(unique(lab))==2 ) then output matrix will have a single row containing AUC of each column. If more than two unique labels are present than AUC is calculated for every possible pairing of classes ("n choose 2" of them).
Note
Change log:
0.1.0 Xiurui Zhu - Initiate the function.
See Also
caTools::colAUC
for the original R implementation.
col_auc_vec
for the vectorized version.
Examples
if (require("MASS", quietly = TRUE) == TRUE) {
data(cats)
print(res_cpp <- col_auc(cats[, 2L:3L], cats[, 1L]))
# Validate with caTools::colAUC()
if (require("caTools", quietly = TRUE) == TRUE) {
print(res_r <- caTools::colAUC(cats[, 2L:3L], cats[, 1L]))
identical(res_cpp, res_r)
}
}