IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
fsgt_fisher.m
Go to the documentation of this file.
1 %> Feature subset grader - Fisher's Criterion
2 %>
3 %> @sa clssr_tree, fsgt
4 classdef fsgt_fisher < fsgt
5  methods
6  %> Original code for the Fisher's Criterion:
7  %>
8  %> Copyright R.P.W. Duin, duin@ph.tn.tudelft.nl
9  %> Faculty of Applied Physics, Delft University of Technology
10  %> P.O. Box 5046, 2600 GA Delft, The Netherlands
11  function [grades, idx, threshold] = test(o, X, classes)
12  X1 = X(classes == 0, :);
13  X2 = X(classes == 1, :);
14 
15  % Between-; Within-
16  m = (mean(X1, 1)-mean(X2, 1)).^2;
17  s = std(X1, 0, 1).^2+std(X2, 0, 1).^2+realmin;
18 
19  grades = m./s; % Fisher's ratio
20  [dummy, idx] = max(grades); % Best feature
21 
22  % Computes threshold
23  m1 = mean(X1(:, idx), 1);
24  m2 = mean(X2(:, idx), 1);
25  w1 = m1-m2;
26  if abs(w1) < eps
27  % the means are equal, so the Fisher
28  % criterion (should) become 0. Let us set the thresold
29  % halfway the domain
30  threshold = (max(X1(:, idx), [], 1) + min(X2(:, idx), [], 1))/2;
31  else
32  w2 = (m1*m1-m2*m2)/2;
33  threshold = w2/w1;
34  end;
35  end;
36  end;
37 
38  methods
39  function o = fsgt_fisher(o)
40  o.classtitle = 'Fisher''s Criterion';
41  end;
42  end;
43 end