Appendix CSample Code for Feature Selection

function [data_mod, index_rem,SIM,SIM1,H]=feat_sel_sim_Schweizer_1(data, p)

%    p in (0, \infty) as default p=1. if nargin<3
p=1;
end

l=max(data(:,end)); % #-classes m=size(data,1); % #-samples t=size(data,2)-1; % #-features dataold=data;
tmp=[];
% forming idealvec using arithmetic mean idealvec=zeros(l,t);
for k=1:l idealvec_s(k,:)=mean(data(find(data(:,end)==k),1:t));
end

%scaling data between [0,1] data_v=data(:,1:t); data_c=data(:,t+1); %labels mins_v = min(data_v);
Ones = ones(size(data_v));
data_v = data_v+Ones*diag(abs(mins_v)); for k=1:l
tmp=[tmp;abs(mins_v)]; end
tmp;
idealvec_s = idealvec_s+tmp; maxs_v = max(data_v);
data_v = data_v*diag(maxs_v.^(-1)); idealvec_s=idealvec_s./repmat(maxs_v,l,1); data = [data_v, data_c];
% sample data datalearn_s=data(:,1:t); land=0.1;
% similarities sim=zeros(t,m,l); for j=1:m

for i=1:t
for k=1:l
%%similarity Luca    with p=1
sn_1(i,j,k)=1-(max(0,((1-(1-datalearn_s(j,i)))^p+((1-idealvec_s(k,i))^p)-1)))^(1/p);
sn_2(i,j,k)=1-(max(0,((1-(datalearn_s(j,i)))^p+((1-(1-idealvec_s(k,i)))^p)-1)))^(1/p);
sim(i,j,k)=(max(0,((sn_1(i,j,k))^p+(sn_2(i,j,k))^p))-1)^(1/p); end
end end
%class 1,2,3,4,. n
% SIM(:,:,1) = similarity for class 1
% SIM(:,:,2) = similarity for class 2 SIM=sim;
% reduce number of dimensions in sim sim=reshape(sim,t,m*l)';
SIM1=sim;

% possibility for two different entropy measures
% moodifying zero and one values of the similarity values to work with
% De Luca's entropy measure

Get Automation and Computational Intelligence for Road Maintenance and Management now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.