From: shahnaz fatima on
i saw a code on lda but i am finding it difficult to give examples in real time.
i want to give differnet training and test vectors and test the performance.

i am pasting the code, below which i write my doubts plz i will be thankful if somebody helps.

function error=oneoutfldnn(G,label,k) % number of features=79 here
class=max(label); % class =20; training samples per each class=8 say,
[m,n]=size(G); %% G is the feature extracted matrix, G=160x79( 160=20x8)
error=0;
d=zeros(m-1,1);
for num=1:m;
tri=zeros(m-1,n);
tei=G(num,:)/100;
tel=label(num);
tri(1:num-1,:)=G(1:num-1,:)/100;
trl(1:num-1,:)=label(1:num-1,:);
tri(num:m-1,:)=G(num+1:m,:)/100;
trl(num:m-1,:)=label(num+1:m,:);
means=zeros(class,n);
nums=zeros(class,1);
for i=1:m-1;
nums(trl(i))=nums(trl(i))+1;
means(trl(i),:)=means(trl(i),:)+tri(i,:);
end;
means=means./(nums*ones(1,n));
sb=zeros(n,n);
sw=zeros(n,n);
allmean=mean(tri);
for i=1:class;
sb=sb+nums(i)*(means(i,:)-allmean)'*(means(i,:)-allmean); //---- DOUBT---//
end;
for i=1:m-1;
sw=sw+(tri(i,:)-means(trl(i),:))'*(tri(i,:)-means(trl(i),:));
end;
[a,b]=eig(inv(sw)*sb);
tri=tri*a(:,1:k);
tei=tei*a(:,1:k);
for i=1:m-1;
d(i)=(tri(i,:)-tei)*(tri(i,:)-tei)';
end;
[p,q]=min(d);
% output=num2str(q);
if tel~=trl(q);
error=error+1;
end;
end;

// MY DOBUT IS IN THIS FORMULA ACCORDING TO THEORY,
sb=sb+nums(i)*(means(i,:)-allmean)'*(means(i,:)-allmean);

nums(i) such term is not there. i dont understand why this nums term.

if anybody can plz help me. plz
From: shahnaz fatima on
"shahnaz fatima" <shahnaz1981fat(a)gmail.com> wrote in message <i3u0k3$fbd$1(a)fred.mathworks.com>...
> i saw a code on lda but i am finding it difficult to give examples in real time.
> i want to give differnet training and test vectors and test the performance.
>
> i am pasting the code, below which i write my doubts plz i will be thankful if somebody helps.
>
> function error=oneoutfldnn(G,label,k) % number of features=79 here
> class=max(label); % class =20; training samples per each class=8 say,
> [m,n]=size(G); %% G is the feature extracted matrix, G=160x79( 160=20x8)
> error=0;
> d=zeros(m-1,1);
> for num=1:m;
> tri=zeros(m-1,n);
> tei=G(num,:)/100;
> tel=label(num);
> tri(1:num-1,:)=G(1:num-1,:)/100;
> trl(1:num-1,:)=label(1:num-1,:);
> tri(num:m-1,:)=G(num+1:m,:)/100;
> trl(num:m-1,:)=label(num+1:m,:);
> means=zeros(class,n);
> nums=zeros(class,1);
> for i=1:m-1;
> nums(trl(i))=nums(trl(i))+1;
> means(trl(i),:)=means(trl(i),:)+tri(i,:);
> end;
> means=means./(nums*ones(1,n));
> sb=zeros(n,n);
> sw=zeros(n,n);
> allmean=mean(tri);
> for i=1:class;
> sb=sb+nums(i)*(means(i,:)-allmean)'*(means(i,:)-allmean); //---- DOUBT---//
> end;
> for i=1:m-1;
> sw=sw+(tri(i,:)-means(trl(i),:))'*(tri(i,:)-means(trl(i),:));
> end;
> [a,b]=eig(inv(sw)*sb);
> tri=tri*a(:,1:k);
> tei=tei*a(:,1:k);
> for i=1:m-1;
> d(i)=(tri(i,:)-tei)*(tri(i,:)-tei)';
> end;
> [p,q]=min(d);
> % output=num2str(q);
> if tel~=trl(q);
> error=error+1;
> end;
> end;
>
> // MY DOBUT IS IN THIS FORMULA ACCORDING TO THEORY,
> sb=sb+nums(i)*(means(i,:)-allmean)'*(means(i,:)-allmean);
>
> nums(i) such term is not there. i dont understand why this nums term.
>
> if anybody can plz help me. plz