Search code examples
pythonstatisticsmachine-learningstat

Calculating the Fisher criterion in Python


Is there a python module that when given two vectors x and y, where y is a two-class (0,1), it calculates the Fisher criterion, as shown in the formula here http://compbio.soe.ucsc.edu/genex/genexTR2html/node12.html

Please note that I am not looking to apply Fisher's linear discriminant, only the Fisher criterion :).

Thanks in advance!


Solution

  • Not as far as I can tell, but you could write your own (please test that this result is correct, I'm only going by my understanding of the formula).

    import numpy as np
    
    def fisher_criterion(v1, v2):
        return abs(np.mean(v1) - np.mean(v2)) / (np.var(v1) + np.var(v2))
    

    Which gives, for example,

    >>> fisher_criterion([0, 1, 2], [0, 1])
    0.54545454545454553