fisher文件

源代码在线查看: drawgraph.m

软件大小: 42 K
上传用户: zhangyuntong
关键词: fisher
下载地址: 免注册下载 普通下载 VIP

相关代码

				%%%%%%%%%%%%%%%%%%%%%%%%%% Draw Graph %%%%%%%%%%%%%%%%%%%%%%%%%%
				function DrawGraph(Training,TestSet,E)
				b=[Training.y1,Training.y2,Training.y3,Training.y4];
				% 画测试集的图
				for k=1:4   %要画4张图
				Draw.C1=[1:TestSet.n1-E(k,1);1:TestSet.n1-E(k,1)];    % 第一类中正确样本集合
				Draw.E1=[1:E(k,1);1:E(k,1)];                          % 第一类中错误样本集合
				Draw.C2=[1:TestSet.n2-E(k,2);1:TestSet.n2-E(k,2)];
				Draw.E2=[1:E(k,2);1:E(k,2)];
				c1=0;
				e1=0;
				c2=0;
				e2=0;
				for i=1:TestSet.n
				    y=Training.W*TestSet.X(i,:)'-b(k);
				    if TestSet.CN(i)==1
				        if TestSet.CN(i)*y				            e1=e1+1;
				            Draw.E1(1,e1)=TestSet.X(i,1);
				            Draw.E1(2,e1)=TestSet.X(i,2);                    
				        else
				            c1=c1+1;
				            Draw.C1(1,c1)=TestSet.X(i,1);
				            Draw.C1(2,c1)=TestSet.X(i,2);        
				        end
				    else
				        if TestSet.CN(i)*y				            e2=e2+1;
				            Draw.E2(1,e2)=TestSet.X(i,1);
				            Draw.E2(2,e2)=TestSet.X(i,2);                    
				        else
				            c2=c2+1;
				            Draw.C2(1,c2)=TestSet.X(i,1);
				            Draw.C2(2,c2)=TestSet.X(i,2);        
				        end
				    end
				end
				X1=[145:185];
				X2=(b(k)-X1*Training.W(1))/Training.W(2);
				subplot(2,2,k);
				plot(Draw.C1(1,:),Draw.C1(2,:),'x',Draw.E1(1,:),Draw.E1(2,:),'rx',...   % 画正类样本
				     Draw.C2(1,:),Draw.C2(2,:),'o',Draw.E2(1,:),Draw.E2(2,:),'ro',...
				     X1,X2);
				title(['y' int2str(k)]);
				end
				%%%%%%%%%%%%%%%%%%%%%%%% Draw Graph End %%%%%%%%%%%%%%%%%%%%%%%%			

相关资源