-
Notifications
You must be signed in to change notification settings - Fork 0
/
corrSel.m
34 lines (34 loc) · 1.05 KB
/
corrSel.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function index = corrSel( data, label )
%CORRSEL Correlation-based feature selectio
%
% data .................input data matrix (each row is an observetion)
% label.................ground-truth
%
%USAGE
% index=corrSel(feature,class)
% selected_features=feature(:,index)
%
%EXPLANATION
% High correlation among features and low correlation between
% labels negatively affect classifier performance. In other
% words, features that have low linear relations with other
% features and high linear relations with labels yield to better
% performance in terms of accuracy
%
% Authored by , Apdullah Yay?k 2017
C=zeros(1, size(data,2));
for i=1:size(data,2)
switch isnan(abs(corr(data(:,i), label)))
case 1
C(i)=0;
otherwise
C(i)=abs(corr(data(:,i), label));
end
end
sortedC=sort(C);
index=zeros(1, size(data,2));
for j=0:size(data,2)-1
p=find(C==sortedC(end-j));
index(j+1)=p(1);
end
end