Fisher's linear discriminant analysis (FLDA) looks for a projection to dimensions that separates classes as well as possible. With class means , overall mean and class sizes , define the scatter matrices
and the criterion (ratio of determinants).
Implement:
flda_fit(X, y, K): return the (D, K) matrix , where is the symmetric inverse square root of and the columns of are the unit-norm eigenvectors of for its largest eigenvalues, in decreasing order. Make each column of sign-unique: flip it so that its entry with the largest absolute value is positive. Raise ValueError if or .fisher_score(W, X, y): return as a float for any (D, K) matrix .Labels are integers ; assume is positive definite.