IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
feacons_kun.m
Go to the documentation of this file.
1 %>@ingroup maths
2 %> @file
3 %> @brief Kuncheva's feature consistency index
4 %>
5 %> <h3>References</h3>
6 %>
7 %> Kuncheva, L. I. A stability index for feature selection, 390-395.
8 %>
9 %> @param s1 subset 1 of feature indexes
10 %> @param s2 subset 2 of feature indexes
11 %> @param nf Total number of possible features
12 function y = feacons_kun(s1, s2, nf)
13 
14 k = numel(s1);
15 
16 if numel(s2) ~= k
17  irerror('Two subsets must have same number of elements!');
18 end;
19 
20 if nf < k
21  irerror('Number of features must be >= subset cardinality!');
22 end;
23 
24 
25 % The below is around 4.8 times faster than r = numel(intersect(s1, s2));
26 %
27 % [A, B] = meshgrid(s1, s2);
28 % temp = A == B;
29 % r = sum(temp(:) & 1)/2;
30 %
31 % However, this is around 14-15 times faster than r = numel(intersect(s1, s2))
32 s1 = s1(:);
33 s2 = s2(:)';
34 n1 = length(s1);
35 n2 = length(s2);
36 temp = s1(:, ones(1, n2)) == s2(ones(1, n1), :);
37 r = sum(temp(:) & 1);
38 
39 
40 a = k^2/nf;
41 y = (r-a)/(k-a+realmin);