bayes classifier1

Download Bayes Classifier1

If you can't read please download the document

Upload: rahul-kumar-meena

Post on 20-Nov-2015

215 views

Category:

Documents


0 download

DESCRIPTION

it representation classification of different classes using cluster based method. In this approach, we also shows boundary.

TRANSCRIPT

function [ ] = bayes_classifier1( training_data,test_data,cov_type )[k1,m1,n1]=size(training_data);[k2,m2,n2]=size(test_data);if(ndims(training_data)~=ndims(test_data) && n1~=n2) error('input data is not good enough');endctrx=[0,0;0,0];for i=1:n1 mtra(:,i)=(mean(training_data(:,:,i)))'; ctra(:,:,i)=(cov(training_data(:,:,i)))'; ctrx=ctrx+ctra(:,:,i);endif(cov_type==1)for i=1:n1gauss{i}=gauss_dis(mtra(:,i),ctra(:,:,i));endelseif(conv_typr==2) ctrx=ctrx*(1/n1);for i=1:n1gauss{i}=gauss_dis(mtra(:,i),ctrx);endendfor i=1:n1x=gauss{i};b=test_data(:,:,i)';for j=1:n2for k=1:k2d(j,k)=x(b(:,i));endend[x,y1]=max(d);y(:,:,i)=y1;endmvalue11=length(find(y(:,:,1)==1))/length(y(:,:,1));mvalue12=length(find(y(:,:,1)==2))/length(y(:,:,1));mvalue13=length(find(y(:,:,1)==3))/length(y(:,:,1));mvalue21=length(find(y(:,:,2)==1))/length(y(:,:,2));mvalue22=length(find(y(:,:,2)==2))/length(y(:,:,2));mvalue23=length(find(y(:,:,2)==3))/length(y(:,:,2));mvalue31=length(find(y(:,:,3)==1))/length(y(:,:,3));mvalue32=length(find(y(:,:,3)==2))/length(y(:,:,3));mvalue33=length(find(y(:,:,3)==3))/length(y(:,:,3));mvalue=[mvalue11,mvalue12,mvalue13;mvalue21,mvalue22,mvalue23;mvalue31,mvalue32,mvalue33];hold on ;DE_boundary(training_data(:,:,1),training_data(:,:,2),training_data(:,:,3));plot(training_data(:,1,1),training_data(:,2,1),'r.',training_data(:,1,2),training_data(:,2,2),'g.',training_data(:,1,3),training_data(:,2,3),'b.',test_data(:,1,1),test_data(:,2,1),'y*',test_data(:,1,2),test_data(:,2,2),'m*',test_data(:,1,3),test_data(:,2,3),'c*');hold off;confusion_matrix(mvalue,3);end