⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainga7.m

📁 GA/SVM 程序包含三个文件: 1。MainGA12.m 2。selectGA12.m 3。svmc12.m MainGA12.m是主文件
💻 M
字号:
function mainGA()
%jin liu yi jianyan d jieguo
clear;
disp(sprintf('************************ Data file format ************************\n'));
disp(sprintf('First row indicates class distinction (by integers, starting from 1, 2, ...).\n'));
disp(sprintf('The second row onwards consists of the data itself.\n'));
disp(sprintf('No non-numerical entries are allowed, hence no labels for samples and genes.\n'));
disp(sprintf('************************ Start program ************************\n'));
xint2=rand(6,31);

%host = input('Enter folder name (start and end with \\ for Windows system \n or / for UNIX): ','s');
host='\gatest\';
%filename = input('Enter training data filename: ','s');
%filename = 'trainC.txt';
filename = 'ALLdataTrain.m';
%i_filename = input('Enter test data filename: ','s');
%i_filename = 'testC.txt';
i_filename = 'ALLdataTest.m';

%lowNP = input('Enter Rmin:'); np = input('Enter Rmax:');

lowNP =10;
np =10;

%selMet = input('Enter 0 for roulette wheel, 1 for stochastic universal selection: ');
selMet =0;
if (selMet ~= 0 & selMet ~= 1)
   selMet = 0;
end

options(4) = selMet;

%xover = input('Enter 0 for one-point crossover, 1 for uniform crossover: ');
xover = 1;
if (xover ~= 0 & xover ~= 1)
   xover = 0;
end

options(5) = xover;

%popnsize = input('Population size? ');  
popnsize =12;
%numgens = input('Maximum number of generations? ');


numgens =10;



%pc = input('Crossover rate (value between 0 and 1)? ');  
pc =1;
%pm = input('Mutation rate (value between 0 and 1)? ');
pm =0.005;
%seedNum = input('Enter zero or any positive integer for initial seeding: ');
seedNum=0;
%useIT = input('Enter (0/1) for fitness function (without/with) independent test error rate: ');
useIT =1;

disp(sprintf('A result file will be created in the specified folder\n'));


%read file to obtain genes
datas = dlmread(filename, '\t');

realClass = datas(1,:); %first row indicates class
nGene = size(datas,1);
datas = datas(2:nGene,:);

i_datas = dlmread(i_filename, '\t');

i_realClass = i_datas(1,:);
i_nGene = size(i_datas,1);
i_datas = i_datas(2:nGene,:);
disp(size(datas));

if (useIT == 1)
   %fun = 'evaluator';
   fun = 'svmc7';
else
   fun = 'evaluator_modf';
end

direct = strcat(host,'results_',num2str(lowNP),'_',...
   num2str(np),'_');
disp(sprintf('low = %g, high = %g\n',lowNP,np));

warning off;
%%%%%%%%%%%%%%%%%%5

options(3) = 0; %p
options(2) = 0; %p
options(6) = 1; %p
options(1) = 1; %p

vlb = []; vub = [];

for i=1:1
     vlb = [vlb lowNP]; vub = [vub np];
end
   
for i=2:np+1
     vlb = [vlb 1]; vub = [vub size(datas,1)];
end
      
   %rand('state',seedNum); %reset
   
   setNum = 1; %just a results file additional label
[xpopn,fitness,meanf,maxf,xopt]=selectGA7(fun,popnsize,pc,pm,numgens,...
   vlb,vub,options,datas,realClass,i_datas,i_realClass,setNum,direct);

disp(sprintf('************************ End program ************************\n'));

 % end of chose
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -