Statistical significance (p-value) for comparing two classifiers with respect to (mean) ROC AUC, sensitivity and specificity

I have a test set of 100 cases and two classifiers.

I generated predictions and computed ROC AUC, sensitivity and specificity for both classifiers.

Question 1: How can I compute p-value to check if one is significantly better than the other with respect to all scores (ROC AUC, sensitivity, specificity)?


Now, for the same test set of 100 cases, I have different and independent feature assignments for each case.
This is because my features are fixed but subjective and provided by multiple (5) subjects.

So, I evaluated my two classifiers again for 5 “versions” of my test set and obtained 5 ROC AUCs, 5 sensitivities and 5 specificities for both classifiers.
Then, I computed the mean of each performance measure for 5 subjects (mean ROC AUC, mean sensitivity and mean specificity) for both classifiers.

Question 2: How can I compute p-value to check if one is significantly better than the other with respect to mean scores (mean ROC AUC, mean sensitivity, mean specificity)?


Answers with some example python (preferably) or MatLab code are more than welcome.

Answer

Wojtek J. Krzanowski and David J. Hand ROC Curves for Continuous Data (2009) is a great reference for all things related to ROC curves. It collects together a number of results in what is a frustratingly broad literature base, which often uses different terminology to discuss the same topic.

Additionally, this book offers commentary and comparisons of alternative methods which have been derived to estimate the same quantities, and points out that some methods make assumptions which may be untenable in particular contexts. This is one such context; other answers report the Hanley & McNeil method, which assumes the binormal model for distributions of scores, which may be inappropriate in cases where the distribution of class scores are not (close to) normal. The assumption of normally distributed scores seems especially inappropriate in modern contexts, typical common models such as tend to produce scores with a “bathtub” distribution for classification tasks (that is, distributions with high densities in the extremes near 0 and 1).

Question 1 – AUC

Section 6.3 discusses comparisons of ROC AUC for two ROC curves (pp 113-114). In particular, my understanding is that these two models are correlated, so the information about how to compute r is critically important here; otherwise, your test statistic will be biased because it doesn’t account for the contribution of correlation.

For the case of uncorrelated ROC curves not based on any parametric distributional assumptions, statistics for tets and confidence intervals comparing AUCs can be straightforwardly based on estimates ^AUC1 and ^AUC2 of the AUC values, and estimates of their standard deviations S1 and S2, as given in section 3.5.1:

Z=^AUC1^AUC2S21+S22

To extend such tests to the case in which the same data is used for both classifiers, we need to take account of the correlation between the AUC estimates:
z=^AUC1^AUC2S21+S22rS1S2

where r is the estimate of this correlation. Hanley and McNeil (1983) made such an extension, basing their analysis on the binormal case, but only gave a table showing how to calculate the estimated correlation coefficient r from the correlation rP of the two classifiers within class P, and the correlation of rn of the two classifiers within class N, saying that the mathematical derivation was available upon request. Various other authors (e.g. Zou, 2001) have developed tests based on the binormal model, assuming that an appropriate transformation can be found which will simultaneously transform the score distributions of classes P and N to normal.

DeLong et al (1988) took advantage of the identity between AUC and the Mann-Whitney test statistic, together with results from the theory of generalized U-statistics due to Sen (1960), to derive an estiamte of the correlation between the AUCs that does not rely on the binormal assumption. In fact, DeLong et al (1988) presented the following results for comparisons between k2 classifiers.

In Section 3.5.1, we showed that the area under the empirical ROC curve was equal to the Mann-Whitney U-statistic, and was given by

^AUC=1nNnPnNi=1nPj=1[I(sPj>sNi)+12I(sPj=sNi)]
where sPi,i=1,,nP are the score for the class P objects and sNj,j=1,,nN are the scores for the class N objects in the sample. Suppose that we have k classifiers, yielding scores srNj,j=1nN and srPi,j=1,,nP [I corrected an indexing error in this part – Sycorax], and ^AUCr,r=1,,k. Define

Vr10=1nNnNj=1[I(srPi>srNj)+12I(srPi=srNj)],i=1,,nP
and
Vr01=1nPnPi=1[I(srPi>srNj)+12I(srPi=srNj)],j=1,,nN

next, define the k×k matrix W10 with (r,s)th element
wr,s10=1nP1nPi=1[Vr10(sPi)^AUCr][Vs10(sPi)^AUCs]
and the k×k matrix W01 with (r,s)th element
wr,s01=1nN1nNi=1[Vr01(sNi)^AUCr][Vs01(sNi)^AUCs]
Then the estiamted covariance matrix for the vector (^AUC1,,^AUCk) of the estimated areas under the curves is
W=1nPW10+1nNW01 with elements wr,s. This is a generalization of the result for the estimated variance of a single estiamted AUC, also given in section 3.5.1. In the case of two classifiers, the estiamted correlation r between the estimated AUCs is thus given by w1,2w1,1w2,2 which can be used in z above.

Since another answers gives the Hanley and McNeil expressions for estimators of AUC variance, here I’ll reproduce the DeLong estimator from p. 68:

The alternative approach due to DeLong et al (1988) and exemplified by Pepe (2003) gives perhaps a simpler estimate, and one that introduces the extra useful concept of a placement value. The placement value of a score s with reference to a specified population is that population’s survivor function at s. This the placement value for s in population N is 1F(s) and for s in population P it is 1G(s). Empirical estimates of placement values are given by the obvious proportions. Thus the placement value of observation sNi in population P denoted sPNi, is the proportion of sample values from P that exceed sNi, and var(sNPi) is the variance of the placement values of each observation from N with respect to population P…

The DeLong et al (1988) estimate of variance of ^AUC is given in terms of these variances:
s2(^AUC)=1nPvar(sNPi)+1nNvar(sPNi)

Note that F is the cumulative distribution function of the scores in population N and G is the cumulative distribution function of the scores in population P. A standard way to estimate F and G is to use the . The book also provides some alternative methods to the ecdf estimates, such as kernel density estimation, but that is outside the scope of this answer.

The statistics Z and z may be assumed to be standard normal deviates, and statistical tests of the null hypothesis proceed in the usual way. (See also: )

This is a simplified, high-level outline of how hypothesis testing works:

  • Testing, in your words, “whether one classifier is significantly better than the other” can be rephrased as testing the null hypothesis that the two models have statistically equal AUCs against the alternative hypothesis that the statistics are unequal.

  • This is a two-tailed test.

  • We reject the null hypothesis if the test statistic is in the critical region of the reference distribution, which is a standard normal distribution in this case.

  • The size of the critical region depends on the level α of the test. For a significance level of 95%, the test statistic falls in the critical region if z>1.96 or z<1.96. (These are the α/2 and 1α/2 quantiles of the standard normal distribution.) Otherwise, you fail to reject the null hypothesis and the two models are statistically tied.

Question 1 - Sensitivity and Specificity

The general strategy for comparing sensitivity and specificity is to observe that both of these statistics amount to performing statistical inference on proportions, and this is a standard, well-studied problem. Specifically, sensitivity is the proportion of population P that has a score greater than some threshold t, and likewise for specificity wrt population N:
sensitivity=tp=P(sP>t)1specificity=fp=P(sN>t)

The main sticking point is developing the appropriate test given that the two sample proportions will be correlated (as you've applied two models to the same test data). This is addressed on p. 111.

Turning to particular tests, several summary statistics reduce to proportions for each curve, so that standard methods for comparing proportions can be used. For example, the value of tp for fixed fp is a proportion, as is the misclassification rate for fixed threshold t. We can thus compare curves, using these measures, by means of standard tests to compare proportions. For example, in the unpaired case, we can use the test statistic (tp1tp2)/s12, where tpi is the true positive rate for curve i as the point in question, and s212 is the sum of the variances of tp1 and tp2...

For the paired case, however, one can derive an adjustment that allows for the covariance between tp1 and tp2, but an alternative is to use McNemar's test for correlated proportions (Marascuilo and McSweeney, 1977).

The is appropriate when you have N subjects, and each subject is tested twice, once for each of two dichotomous outcomes. Given the definitions of sensitivity and specificity, it should be obvious that this is exactly the test that we seek, since you've applied two models to the same test data and computed sensitivity and specificity at some threshold.

The McNemar test uses a different statistic, but a similar null and alternative hypothesis. For example, considering sensitivity, the null hypothesis is that the proportion tp1=tp2, and the alternative is tp1tp2. Re-arranging the proportions to instead be raw counts, we can write a contingency table
Model 1 Positive at tModel 1 Negative at tModel 2 Positive at tabModel 2 Negative at tcd
where cell counts are given by counting the true positives and false negatives according to each model

a=nPi=1I(s1Pi>t)I(s2Pi>t)b=nPi=1I(s1Pit)I(s2Pi>t)c=nPi=1I(s1Pi>t)I(s2Pit)d=nPi=1I(s1Pit)I(s2Pit)

and we have the test statistic
M=(bc)2b+c
which is distributed as χ21 a chi-squared distribution with 1 degree of freedom. With a level α=95%, the null hypothesis is rejected for M>3.841459.

For the specificity, you can use the same procedure, except that you replace the srPi with the srNj.

Question 2

It seems that it is sufficient to merge the results by averaging the prediction values for each respondent, so that for each model you have 1 vector of 100 averaged predicted values. Then compute the ROC AUC, sensitivty and specificity statistics as usual, as if the original models didn't exist. This reflects a modeling strategy that treats each of the 5 respondents' models as one of a "committee" of models, sort of like an ensemble.

Attribution
Source : Link , Question Author : kostek , Answer Author : Sycorax

Leave a Comment