1
$\begingroup$

I want to compare the classification performance of two heuristics: $h_0$ and $h_1$. I have around 700 samples for which I know the output class $c$ and the results of the two heuristics $c_{\textit{h_0}}, c_{\textit{h_1}}$. That is, for each sample I have $\text{sample}_{\textit{id}}, c, c_{\textit{h_0}}, c_{\textit{h_1}}$.

$h_0$ has around ~71% correct predictions of the output class and $h_1$ has around ~77% correct. What I want to calculate now is whether this performance difference is just by chance or if the prediction performance of $h_1$ is statistical significant better than that of $h_0$.

I have found Fisher's exact test, but I don't know whether I can just put my data in there like the following matrix to calculate a p-value.

$$ \begin{matrix} & h_0 & h_1 \\ \text{correct prediction} & 497 & 539 \\ \text{wrong prediction} & 203 & 161 \end{matrix} $$

I don't know if I can calculate the p-value like that or if I'm completely on the wrong track. I would really appreciate it if someone could point me in the right direction.

$\endgroup$
  • $\begingroup$ Did you get predictions from both heuristics for each sample, or did you use different samples for each heuristic? $\endgroup$ – gung Dec 7 '15 at 12:44
  • $\begingroup$ If the former, do you know the correct / wrong status for each sample? $\endgroup$ – gung Dec 7 '15 at 13:04
  • $\begingroup$ I got the predictions of both heuristics for the same samples. Currently I only have the end results, i.e. $h_0$ has 71% correct classifications but I can get the correct/wrong status for each sample if that's necessary. $\endgroup$ – Daniel Dec 7 '15 at 13:17
2
$\begingroup$

You have matched pairs. That is, you (ultimately) have a correct / wrong classification for each sample. (You will need to get this status for each sample to validly assess the results.) As a result of this fact (among others), Fisher's exact test is not appropriate for your data.

Instead, you should format your table so that each count indexes the status of a given matched pair. In other words, you would enumerate the number of pairs for which both classifications were correct, only $h_0$ was correct, only $h_1$ was correct, and where both classifications were wrong. In the end, the sum of the counts in the table will be half of your current table. For example, your table might end up looking like this (totally made up):

tab = as.table(matrix(c(400, 150,
                         50, 100), nrow=2, byrow=2))
rownames(tab) <- colnames(tab) <- c("correct", "wrong")
names(dimnames(tab)) = c("h0", "h1")
tab
#          h1
# h0        correct wrong
#   correct     400   150
#   wrong        50   100

You can assess if the heuristics differ in predictive accuracy using McNemar's test. (I have explained McNemar's test here and here.)

mcnemar.test(tab)
#  McNemar's Chi-squared test with continuity correction
# 
# data:  tab
# McNemar's chi-squared = 49.005, df = 1, p-value = 2.553e-12

Let me note that there may be a better way to evaluate these heuristics. Many models (e.g., logistic regression) will output a continuous value, which people then dichotomize to generate the predicted classifications. If your case is like this, you would do better to compare the outputted continuous values, rather than the classifications. Two possibilities would be to compare the area under the Receiver Operating Characteristic (ROC) curve (see here and here, e.g.), or to compare a proper score (such as the Brier score).

$\endgroup$
  • $\begingroup$ Thank you for your help, especially for the nice explanations of the McNemar's Test. I'll try to understand it and apply it on my problem! $\endgroup$ – Daniel Dec 8 '15 at 9:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.