2
$\begingroup$

I'm trying to replicate a study where the author used the McNemar test to assess the performance of classification compared to random classification. I have the original classifier and I'm using R to do the McNemar test, but I don't know how I'm supposed to obtain the random classification, can someone help me?

$\endgroup$
1
  • $\begingroup$ McNemar's test is a two-paired-sample test. If by random classification you mean a specific classificator (e.g. a specific random generator) you may simulate the variable with its classification results. If by random classification you mean abstract randomness, you need a one-sample test, such as chi-square test of goodness-of-fit. $\endgroup$
    – ttnphns
    Commented Nov 19, 2014 at 17:14

2 Answers 2

1
$\begingroup$

You might try to contact the author to learn more about what they did. Your description doesn't make sense (which doesn't necessarily mean it's inaccurate or you misunderstood—people do a lot of things that don't make sense). As @ttnphns notes in the comments, McNemar's test is for a paired comparison of yes/no data; you'd use that when comparing two different classifiers on the same dataset (cf., Compare classification performance of two heuristics).

For your situation, to determine if your accuracy is better than would occur by chance alone, you want to do a one-sample test of your classifier's percent correct vs. the proportion correct you would get if you just always guessed the more commonly occurring class.

On the other hand, you could use McNemar's test to determine if your model is biased (in the sense that it guesses one of the classes more often than it 'should'; see: How to calculate information included in R's confusion matrix).

$\endgroup$
0
$\begingroup$

Does the original publication not elaborate on that?

In my understanding, you just "randomly" assign a class to an observation. For starters, you could go with something like:

sample(vector_of_classes, number_of_observations, replace = T)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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