IssamLaradji
IssamLaradji

Reputation: 6855

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!

Upvotes: 1

Views: 5202

Answers (2)

danodonovan
danodonovan

Reputation: 20341

That looks remarkably like Linear Discriminant Analysis - if you're happy with that then you're amply catered for with scikit-learn and mlpy or one of many SVM packages.

Upvotes: 1

Adam Obeng
Adam Obeng

Reputation: 1542

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

Upvotes: 3

Related Questions