亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? genetic_programming.m

?? 這是很有用的模式分類原代碼
?? M
字號:
function [test_targets, best_fun] = genetic_programming(train_patterns, train_targets, test_patterns, params)

% A genetic programming algorithm for classification
%
% 	train_patterns	- Train patterns
%	train_targets	- Train targets
%   test_patterns   - Test  patterns
%	params  		- [Initial function length, Number of generations, Number of solutions]
%
%Outputs
%	test_targets	- Predicted targets
%   func			- The best solution found

IterDisp  = 10;

[Ni, M]   = size(train_patterns);
x		  = train_patterns;
Uc        = unique(train_targets);

%Find parameters
[Flength, Ngenerations, Nsol] = process_params(params);

if (Flength) > 20,
   warning('This may take some time!')
end

%Define basic operators. If division by zero is unwanted, remove the devision operator
warning off %To suppress all those divide by zero warnings
operators	 = [' +'; ' -'; '.*'; './'];
base			 = size(operators,1);
for i = 1:Ni,
   operators(base+i,:) = ['X' num2str(i)];
end

%Define the basic tree shape
leafs = [];
solutions = zeros(1,Nsol); %Pointer to the first leaf in the solution

for i = 1:Nsol;
   solutions(i) = length(leafs) + 1;
   leafs			 = foliage(leafs, operators, Flength);
end

disp(['Starting with ' num2str(Nsol) ' solutions, totaling ' num2str(length(leafs)) ' leaves.'])

best = 0;

%Start doing the mutations
for i = 1:Ngenerations,
   %Rank each solution
   ranking = zeros(1,Nsol);
   for j = 1:Nsol,
      func    = collect_tree(solutions(j), leafs);
      for k = 1:Ni,
         func = strrep(func, ['X' num2str(k)], ['x(' num2str(k) ',:)']);
      end
      
      %Check if this string is a valid solution, and if so, put the ranking into place
      try
         t = eval(func);
         if (length(Uc) == 2)
             t = t > 0;
         else
             t = round(t);
         end
         ranking(j) = sum(t == train_targets) / length(train_targets);
      catch
      end
      
   end
   
   %Display
   if (i/IterDisp == floor(i/IterDisp)),
      disp(['Iteration ' num2str(i) ': Best solution has ' num2str(max(ranking)*100) '% correct (The best so far was ' num2str(best*100) '% correct).'])
   end
      
   %Sort the solutions according to rank
   [m, indices] = sort(ranking);
   indices		 = fliplr(indices);
   
   %It is sometimes good to save the best solution so far, in case the mutations ruin it!
   if (max(ranking) > best),
      best 		= max(ranking);
      best_fun = collect_tree(solutions(indices(1)), leafs);
   end
   
   %Start the genetic operations
   for j = 1:floor(Nsol/2),
      %Select two solutions according to their rank
      s1	= indices(j*2-1);
      s2 = indices(j*2);
      
      %Now do the genetic operators
      %There is no insertion in this implementation, as it generates too many impossible solutions
      
      k	= 1 + floor(3*rand(1));
      switch k,
      case 1,
         %Replications
         %Replicate from 2 to 1 or vice versa?
         if rand(1) > .5,
            temp = s1;
            s1   = s2;
            s2   = temp;
         end
         
         %Find where from to replicate
         node_number1 = walk_along(solutions(s1), leafs);
         node_number2 = walk_along(solutions(s2), leafs);
         [new_node, leafs] = copy(node_number1, leafs);
         
         %Put on left or right?
         if rand(1) > .5,
            %Put on left
            leafs(node_number2).left = new_node;
         else
            leafs(node_number2).right = new_node;
         end
         
      case 2,
         %Crossover
         %First, decide where to do the crossover
         node_number1 = walk_along(solutions(s1), leafs);
         node_number2 = walk_along(solutions(s2), leafs);
         
         %Change pointers by finding which leaf points to each of the leafs to change
         l1 = []; l2 = []; r1 = []; r2 = [];
         for m = 1:length(leafs),
            if ~isempty(leafs(m).left),
               if leafs(m).left == node_number1,
                  l1 = m;
               end
               if leafs(m).left == node_number2,
                  l2 = m;
               end
            end
            if ~isempty(leafs(m).right),
               if leafs(m).right == node_number1,
	               r1 = m;
   	         end
      	      if leafs(m).right == node_number2,
         	      r2 = m;
               end
            end            
         end
         
         if ~isempty([l1 r1]) & ~isempty([l2 r2]),
            if isempty(l1),
               %It is on the right of 1
               if isempty(l2),
                  leafs(r2).right = node_number1;
                  leafs(r1).right = node_number2;
               else
                  leafs(l2).left  = node_number1;
                  leafs(r1).right = node_number2;
               end
            else
               if isempty(l2),
                  leafs(r2).right = node_number1;
                  leafs(l1).right = node_number2;
               else
                  leafs(l2).left  = node_number1;
                  leafs(l1).right = node_number2;
               end
            end
         end
         
      case 3,
         %Mutation
         %Mutate s1 or s2? 
         if rand(1) > .5,
            temp = s1;
            s1   = s2;
            s2   = temp;
         end
         
         %First, decide where to do the mutation
         node_number1 = walk_along(solutions(s1), leafs);
         
         %Choose the new operator
         o1	= 1 + floor(rand(1)*size(operators,1));
         
         %Mutate!
         leafs(node_number1).operator = operators(o1,:);
         
         if strcmp(operators(o1,1),'X'),
            leafs(node_number1).left  = [];
            leafs(node_number1).right = [];
         end
         
      end
      
   end
   
   
end


%Classify test patterns
disp(['Will use a solution with ' num2str(best*100) '% correct for the test patterns'])

dfun    = best_fun;

for k = 1:Ni,
    dfun = strrep(dfun, ['X' num2str(k)], ['test_patterns(' num2str(k) ',:)']);
end

test_targets = eval(dfun);

if (length(Uc) == 2)
    test_targets = test_targets > 0;
end

%END

function [root, leafs] = copy(start_point, leafs)
%Make a copy of a branch, from the start point until its end. Return a pointer to the copy
N	= length(leafs) + 1;
leafs(N).operator = leafs(start_point).operator;

if ~isempty(leafs(start_point).left),
   [root, leafs] = copy(leafs(start_point).left, leafs);
   leafs(N).left = root;
end
if ~isempty(leafs(start_point).right),
   [root, leafs]  = copy(leafs(start_point).right, leafs);
   leafs(N).right = root;
end

root = N;

%END


function node = walk_along(start_point, leafs);
%Find where to mutate a solution along a tree. This is recursive
r = 1 + floor(rand(1)*4);

switch r,
case {1,2},
   %Go no further
   node = start_point;
case 3,
   %If possible, go right
   if ~isempty(leafs(start_point).right),
      node = walk_along(leafs(start_point).right, leafs);
   else
      node = start_point;
   end
case 4,
   %If possible, go left
   if ~isempty(leafs(start_point).left),
      node = walk_along(leafs(start_point).left, leafs);
   else
      node = start_point;
   end
end

%END


function s = collect_tree(pointer, leafs)
%Find the tree function recursively
if ~isempty(leafs(pointer).left),
   s = ['(' collect_tree(leafs(pointer).left, leafs) ')'];
else
	s = [];   
end

s = [s leafs(pointer).operator];

if ~isempty(leafs(pointer).right),
   s = [s '(' collect_tree(leafs(pointer).right, leafs) ')'];
end

%END

function [leafs, N] = foliage(leafs, operators, remaining_depth)
%Recursively add leafs in order to build the initial tree
N			= length(leafs)+1;

if (remaining_depth > 0),
	r		= floor(rand(1)*size(operators,1)) + 1;
   leafs(N).operator = operators(r,:);
   if ~strcmp(leafs(N).operator(1), 'X'),
      %The operator is numeric, so more leafs are needed
      [leafs, added] = foliage(leafs, operators, remaining_depth-1);	      
      leafs(N).left  = added;
      [leafs, added] = foliage(leafs, operators, remaining_depth-1);	      
      leafs(N).right = added;
   else
      leafs(N).left     = [];
	   leafs(N).right    = [];
   end
else
   in = find(operators(:,1) == 'X');
	r	= floor(rand(1)*length(in)) + 1;
   leafs(N).operator = ['X' num2str(r)];
   leafs(N).left     = [];
   leafs(N).right    = [];
end

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩三级伦理片妻子的秘密按摩| 亚洲人成精品久久久久久| 国产欧美一区二区在线| 亚洲乱码中文字幕| 男人的j进女人的j一区| 成人av动漫网站| 精品国产自在久精品国产| 一区二区三区小说| 成人午夜看片网址| 26uuu欧美日本| 蜜桃av一区二区三区| 欧洲精品一区二区三区在线观看| 久久免费看少妇高潮| 日韩黄色小视频| 在线观看免费一区| 亚洲同性gay激情无套| 国产精品综合二区| 日韩一区二区免费高清| 亚洲五码中文字幕| 99r国产精品| 中文字幕一区三区| 国产91富婆露脸刺激对白| 日韩精品一区二| 日韩电影免费一区| 91精品视频网| 婷婷久久综合九色综合绿巨人| 91一区在线观看| 综合婷婷亚洲小说| 91麻豆国产福利在线观看| 国产精品天干天干在观线| 国产乱理伦片在线观看夜一区| 日韩一区二区视频在线观看| 免费在线观看成人| 欧美成人福利视频| 精品一区二区综合| 国产精品久久久久久久午夜片| 久久99精品久久久久久动态图| 91精品麻豆日日躁夜夜躁| 午夜天堂影视香蕉久久| 欧美精品一卡二卡| 久久电影网站中文字幕| 日韩一级二级三级精品视频| 另类小说视频一区二区| 日韩精品在线看片z| 久久99最新地址| 国产三级三级三级精品8ⅰ区| 狠狠色丁香久久婷婷综合_中| 26uuu国产日韩综合| 国产成人av一区二区三区在线 | 国产精品区一区二区三| 成人免费电影视频| 亚洲激情自拍视频| 欧美巨大另类极品videosbest | 在线成人免费视频| 久久99最新地址| 日本一区二区免费在线| 99精品视频在线免费观看| 亚洲午夜视频在线观看| 日韩欧美激情四射| 国产成a人亚洲精品| 亚洲欧美另类在线| 777亚洲妇女| 国产精品1区2区3区在线观看| 国产精品理论片在线观看| 欧美在线你懂的| 国产原创一区二区| 一色桃子久久精品亚洲| 91精品国产综合久久福利软件| 国内精品伊人久久久久av影院| 调教+趴+乳夹+国产+精品| 精品少妇一区二区三区在线播放 | 国产乱人伦偷精品视频免下载| 中国av一区二区三区| 欧美无砖砖区免费| 国产一区二区视频在线| 一区二区三区不卡视频在线观看| 欧美日本免费一区二区三区| 国产精品白丝av| 亚洲综合色自拍一区| 久久伊人蜜桃av一区二区| 91免费看`日韩一区二区| 青青草成人在线观看| 亚洲美女在线一区| 国产日韩欧美高清| 欧美三级乱人伦电影| 成人伦理片在线| 麻豆精品在线播放| 亚洲大片一区二区三区| 国产精品不卡一区| 久久丝袜美腿综合| 欧美在线啊v一区| 国产传媒久久文化传媒| 青青青伊人色综合久久| 亚洲欧美区自拍先锋| 久久久久久久电影| 91精品国产欧美一区二区18| 91视频.com| 国产精品一二二区| 免费在线观看不卡| 性做久久久久久久免费看| 亚洲视频狠狠干| 欧美激情综合在线| 久久综合狠狠综合久久激情| 91精品国产入口| 欧美精品第一页| 在线亚洲高清视频| 在线日韩一区二区| 色综合色狠狠综合色| 成人av电影在线观看| 成人精品鲁一区一区二区| 国产尤物一区二区| 国产主播一区二区| 蜜臀91精品一区二区三区| 视频一区视频二区中文| 亚洲一区精品在线| 亚洲在线视频网站| 亚洲观看高清完整版在线观看| 亚洲色图欧美激情| 加勒比av一区二区| 91.com在线观看| 欧美主播一区二区三区| 99国产精品99久久久久久| 91在线观看地址| 欧美三级午夜理伦三级中视频| 91国内精品野花午夜精品| 欧美在线影院一区二区| 欧美美女一区二区三区| 91麻豆精品国产无毒不卡在线观看| 欧美三级资源在线| 欧美丰满嫩嫩电影| 精品国产污污免费网站入口 | 欧美日韩高清不卡| 欧美日韩国产精选| 91精品国产综合久久福利| 日韩西西人体444www| 欧美日韩视频在线观看一区二区三区 | 欧美日韩久久一区二区| 欧美精品丝袜久久久中文字幕| 欧美精品色综合| 久久香蕉国产线看观看99| 国产精品女人毛片| 亚洲自拍与偷拍| 久久精品99国产精品| 成人性生交大片免费| 91福利小视频| 日韩欧美一区中文| 国产精品色噜噜| 夜夜精品视频一区二区| 激情久久五月天| 色天天综合色天天久久| 日韩欧美在线不卡| 18成人在线观看| 蜜桃av一区二区| 一本大道久久a久久综合| 91精品欧美久久久久久动漫| 国产亚洲欧美中文| 丝袜脚交一区二区| 成人少妇影院yyyy| 日韩一级二级三级精品视频| 国产精品久久久久久久久果冻传媒 | 日韩午夜在线播放| 亚洲欧美激情在线| 紧缚奴在线一区二区三区| 日本久久电影网| 久久精品视频一区二区三区| 亚洲成人在线免费| 99久久99久久免费精品蜜臀| 日韩三级在线免费观看| 亚洲欧美偷拍另类a∨色屁股| 精品一区二区三区在线观看 | 久久精品一区四区| 天天操天天色综合| 色哦色哦哦色天天综合| 久久精品夜夜夜夜久久| 免费国产亚洲视频| 欧美日韩一区二区欧美激情 | 中文字幕国产精品一区二区| 日本成人超碰在线观看| 欧美丝袜自拍制服另类| 亚洲人一二三区| 成人av免费在线播放| 亚洲国产精品t66y| 国产剧情一区在线| 日韩欧美成人一区二区| 日本亚洲三级在线| 欧美视频在线播放| 亚洲美女电影在线| 91在线高清观看| 国产精品对白交换视频| www.久久久久久久久| 欧美激情一区二区三区全黄| 国产一区二区三区综合| 精品免费视频一区二区| 激情五月婷婷综合| 欧美mv日韩mv亚洲| 国产一区二区精品久久99| 欧美va亚洲va| 国产成人精品综合在线观看 | 裸体健美xxxx欧美裸体表演| 欧美午夜免费电影|