col_auc: Column-wise area under ROC curve (AUC)

View source: R/RcppExports.R

col_aucR 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 x.

args

NULL (default) or list of named arguments:

direction

Character vector containing one of the following directions: ">", "<" or "auto" (default), recycled for each feature so different directions can be used for different features.

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

RcppColMetric documentation built on April 4, 2025, 1:25 a.m.