col_auc | R Documentation |
Calculate area under the ROC curve (AUC) for every column of a matrix or data frame. For better performance, data frame is preferred.
col_auc(x, y, args = NULL)
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 |
|
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).
Change log:
0.1.0 Xiurui Zhu - Initiate the function.
caTools::colAUC
for the original R implementation.
col_auc_vec
for the vectorized version.
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)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.