The Q-statistic is a pairwise diversity measure built from the same four counts as disagreement. It compares the chance that both classifiers are right, or both wrong, against the chance that exactly one of them is right.
With N_11, N_10, N_01 and N_00 counting examples by the correctness pattern of the two classifiers (1 means correct), the statistic is
Q = (N_11 * N_00 - N_01 * N_10) / (N_11 * N_00 + N_01 * N_10).
Implement q_statistic(correct_a, correct_b), where both inputs are 1-D boolean or 0/1 arrays of the same length.
Q as a float. It lies in [-1, 1]: 1 means the errors always coincide, -1 means the classifiers are never right together and never wrong together.ValueError because Q is undefined.ValueError.ValueError.Compute the four counts with boolean masks: a & b, a & ~b, ~a & b, and ~a & ~b.
No results yet
Run your code to check it against the examples, or submit to run every test.