function callGeneticAlgo
global mat
global trainInd
global testInd
[trainInd,~,testInd] = dividerand(1420,0.7,0,0.3);
global counter
global errList
counter = 1;
errList = [];
fileName= '../features/alltopPNPDMF.feature' ;
mat = load(fileName);
[x,fval,exitflag,output,population,score] = gaFeaSelection(1588,100,10800); % param1 = #feature excludig label
% param2 = population size
% param3 = sec to test (3 hour = 10800 sec)
dlmwrite('selected.GA',x,'delimiter','\n');
display('Done');
end
function [x,fval,exitflag,output,population,score] = gaFeaSelection(nvars,PopulationSize_Data,TimeLimit_Data)
% This is an auto generated MATLAB file from Optimization Tool.
% Start with the default options
options = gaoptimset;
% Modify options setting
options = gaoptimset(options,'PopulationType', 'bitString');
options = gaoptimset(options,'PopulationSize', PopulationSize_Data);
options = gaoptimset(options,'TimeLimit', TimeLimit_Data);
options = gaoptimset(options,'MutationFcn', { @mutationuniform [] });
options = gaoptimset(options,'Display', 'iter');
options = gaoptimset(options,'PlotFcns', { @gaplotbestf });
[x,fval,exitflag,output,population,score] = ...
ga(@feaSelobjFun,nvars,[],[],[],[],[],[],[],options);
end
function [ evalValue ] = feaSelobjFun( x )
%FEASELOBJFUN Summary of this function goes here
% Detailed explanation goes here
global mat
global trainInd
global testInd
global counter
global errList
Data = mat(:,1:end-1);
Label = mat(: , end);
selectedFeature = Data(:,(x~=0))*diag(x(x~=0));
svmStruct = svmtrain(selectedFeature(trainInd,:),Label(trainInd),...
'kernel_function','linear' ,...
'method' , 'SMO' , 'kktviolationlevel',.55);
predictedOut = svmclassify(svmStruct,selectedFeature(testInd,:));
[X,Y,Thr,AUC] = perfcurve(Label(testInd),predictedOut,1);
evalValue = 1-AUC;
errList(counter) = fval;
counter = counter + 1;
end
Hi... This is feature subset selection or feature selection ??? can you provide us a sample output please..
ReplyDeleteplease can you put alink to download source files
ReplyDelete