gnalgo.m

来自「Advanced Human Mood detection technique 」· M 代码 · 共 94 行

M
94
字号
function gnalgo()
clc;
clear all ;
load imdb.dat;
lim=500;
disp('Generating initial population...');
pop = initpop();
%pop = floor(6*rand(9,20);
newpop=zeros(27,20);
for gen=1:lim
    f=fitfun(pop,imdb);
    rank=rankfn(f);
    newpop=elite(pop,rank,newpop);
    newpop=crossover(pop,f,newpop);
    newpop=mutation(newpop);
    pop=newpop;
end

 f=fitfun(pop,imdb);
 rank=rankfn(f);
 disp(f);
 disp(pop);
 %disp('0--> Undetermined, 1 --> Happy, 2-->Sad , 3 --> Surprised, 4--> Angry, 5-->Normal');
 
  
 mx=max(rank);
 x=find(rank==mx);
 ret=pop(:,x(1));
 
 count = 1;
 a = 'If EO = ';
 b = 'If MO  = ';
 c = 'If EC = ';
 d = ' and ';
 e = ' then ';
 
 for i = 1:3
     switch i
    case 1
       x = 'LOW';
         case 2
              x = 'MED';
        otherwise
       x = 'HIGH';
     end
       
     
     for j = 1:3
         
         switch j
    case 1
       y = 'LOW';
         case 2
              y = 'MED';
        otherwise
       y = 'HIGH';
         end
       
         
         for k = 1:3
             switch k
    case 1
       z = 'LOW';
         case 2
              z = 'MED';
        otherwise
       z = 'HIGH';
             end
       
           
             switch ret(count)
    case 1
       em = 'HAPPY';
         case 2
              em = 'SAD';
                 case 3
              em = 'SURPRISE';
                 case 4
              em = 'ANGRY';
                 case 5
              em = 'NORMAL';
        otherwise
       em = 'UNDETERMINED';
             end
             
             t = strcat(a,x,d,b,y,d,c,z,e,em);
             disp(t);
             count = count + 1;
         end
     end
 end
 
 
 

⌨️ 快捷键说明

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