该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
% Settings
rng('shuffle');
for data_set = 1:4
Dataset = num2str(data_set);
multilevel = 4;
ep_array = [1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1];
C = 10;
Out_Local = fopen([Dataset,'_PrivLocal_SVM.txt'],'w');
sh
RawData = load(['Data',Dataset,'.dat']);
[RawRow, RawCol] = size (RawData);
RawData_min = min(RawData,[],1);
RawData_max = max(RawData,[],1);
Data = (RawData-ones(RawRow,1)*RawData_min)./ (ones(RawRow,1)*(RawData_max-RawData_min)); % X,Y->[0,1]
Data = [(Data(:,1:end-1)-0.5).*2, ones(RawRow,1), (Data(:,end)-0.5).*2]; % X,Y->[-1,1]; add bias b
[DataRow, DataCol] = size (Data);
d = DataCol-1;
% Mutation settings
mutScale = 0.5;
mutResize = 0.95;
% End of Mutation setting
disp('Start...');
for stable = 1:10
fold = rand(DataRow, 1);
for foldnum = 1:5
SepLine = (0.2*(foldnum-1)
Test = Data(SepLine,:);
[TestRow, ~] = size(Test);
Train = Data(not(SepLine),:);
[TrainRow, ~] = size(Train);
for Epsilon = 1:10
ep = ep_array(Epsilon);
for multirun = 1:multilevel
disp([stable, foldnum, Epsilon, multirun]);
iteration = max(round( TrainRow*ep/800 ), 1);
disp(iteration);
seedsRemain = zeros(1, d);
Seeds = zeros(2*d, d);
curScale = mutScale;
for nextg = 1:d
mutation = zeros(1, d);
mutation(nextg) = curScale;
Seeds(nextg*2-1:nextg*2,:) = [seedsRemain+mutation; seedsRemain-mutation];
end
for it = 1:iteration
seedsUtility = SVMScore(Train, Seeds, C);
Sensitivity = 4*C*curScale;
seedsSelected = ExpMech(seedsUtility, ep/iteration, Sensitivity);
seedsRemain = Seeds(seedsSelected,:);
curScale = curScale * mutResize;
for nextg = 1:d
mutation = zeros(1, d);
mutation(nextg) = curScale;
Seeds(nextg*2-1:nextg*2,:) = [seedsRemain+mutation; seedsRemain-mutation];
end
end
Noised = SVMTest(Test, seedsRemain)/TestRow;
disp(Noised);
fprintf(Out_Local, '%d %d %d %d %e\n', stable, foldnum, Epsilon, multirun, Noised);
end
end
end
end
end