multi_roc: Multi-class classification ROC

Description Usage Arguments Details Value References Examples

View source: R/multi_roc.R

Description

This function calculates the Specificity, Sensitivity and AUC of multi-class classifications.

Usage

1
multi_roc(data, force_diag=TRUE)

Arguments

data

A data frame contain true labels of multiple groups and corresponding predictive scores

force_diag

If TRUE, TPR and FPR will be forced to across (0, 0) and (1, 1)

Details

A data frame is required for this function as input. This data frame should contains true label (0 - Negative, 1 - Positive) columns named as XX_true (e.g. S1_true, S2_true and S3_true) and predictive scores (continuous) columns named as XX_pred_YY (e.g. S1_pred_SVM, S2_pred_RF), thus this function allows calcluating ROC on mulitiple classifiers.

Predictive scores could be probabilities among [0, 1] and other continuous values. For each classifier, the number of columns should be equal to the number of groups of true labels. The order of columns won't affect results.

Specificity, Sensitivity, AUC for each group and each method will be calculated. Macro/Micro-average AUC for all groups and each method will be calculated.

Micro-average ROC/AUC was calculated by stacking all groups together, thus converting the multi-class classification into binary classification. Macro-average ROC/AUC was calculated by averaging all groups results (one vs rest) and linear interpolation was used between points of ROC.

AUC will be calculated using function cal_auc().

Value

Specificity

A list of specificities for each group, each method and micro-/macro- average

Sensitivity

A list of sensitivities for each group, each method and micro-/macro- average

AUC

A list of AUCs for each group, each method and micro-/macro- average

Methods

A vector contains the name of different classifiers

Groups

A vector contains the name of different groups

References

http://scikit-learn.org/stable/auto_examples/model_selection/plot_roc.html

Examples

1
2
3
data(test_data)
roc_test <- multi_roc(test_data)
roc_test$AUC 

Example output

Warning messages:
1: In regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
2: In regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
3: In regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
4: In regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
5: In regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
6: In regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
$m1
$m1$G1
[1] 0.7233607

$m1$G2
[1] 0.527619

$m1$G3
[1] 0.9751462

$m1$macro
[1] 0.742042

$m1$micro
[1] 0.8824221


$m2
$m2$G1
[1] 0.3237705

$m2$G2
[1] 0.372381

$m2$G3
[1] 0.4020468

$m2$macro
[1] 0.3665214

$m2$micro
[1] 0.4174394

multiROC documentation built on May 1, 2019, 10:11 p.m.

Related to multi_roc in multiROC...