1 / 16

Pattern recognition lab 6

Pattern recognition lab 6. TA : Nouf Al-Harbi :: nouf200@hotmail.com. Lab objective:. Applying General Bayesian Decision Theory Classify an input feature value into one of three classes. Quick review of General Bayesian Decision Theory. General Bayesian Decision Theory. Quick review .

sailor
Download Presentation

Pattern recognition lab 6

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Pattern recognition lab 6 TA : Nouf Al-Harbi :: nouf200@hotmail.com

  2. Lab objective: • Applying General Bayesian Decision Theory • Classify an input feature value into one of three classes

  3. Quick review of General Bayesian Decision Theory

  4. General Bayesian Decision Theory Quick review

  5. General Bayesian Decision Theory Quick review

  6. General Bayesian Decision Theory Quick review

  7. Part 1 Classify a given input feature value into one of three classes (using General Bayesian Decision Theory)

  8. part 1 Practical Learning 1 • Make a Matlab function that classify a feature value x into one of classes w1,w2, and w3 if you know these info: • P(w1)=P(w2)=P(w3)=1/3 • P(x|w1) ≈N(20,4) • P(x|w2) ≈N(30,3) • P(x|w3) ≈N(40,2) • The loss function is

  9. Full code for i=1:C Pwx(i) = pxw(i) * Pw(i); sum = sum + Pwx(i); end Px = sum; Pwx = Pwx / Px; lamda = zeros(A,C); lamda = [0 1 2; 1 0 1; 2 1 0]; R = zeros(1,A); for i = 1:A sum = 0; for j = 1:C sum = sum + lamda(i,j)*Pwx(j); end R(i) = sum; End mn = R(1); wi = 1; for i = 2:A if( mn > R(i)) mn = R(i); wi = i; end End Result = sprintf('\nAction %d will be taken for x = %d \n', wi, x) • function BayesClassifier3 (x) • C= 3 • A = 3 • Pw = zeros(1,C); • Pw = [ 1/3 1/3 1/3]; • mu = [ 20 30 40]; • sigma = [4 3 2 ]; • pxw = zeros(1,C); • for i=1:C • pxw(i) = normalfn( x, mu(i), sigma(i)); • End • pwx = zeros(1,C); • sum =0;

  10. output Action 1 will be taken for x = 10 Action 3 will be taken for x = 50 Action 2will be taken for x = 30

  11. Part 2 Using of the 4thform of general Bayesian classification (in terms of the likelihoods ratios)

  12. general Bayesian classification (in terms of the likelihoods ratios)

  13. Appling part 1 Practical Learning 1 • Make a Matlab function that draw the relation between likelihood ratios and the threshold value (4th form of BC rule) • P(w1)=2/3 • P(w2)=1/3 • P(x|w1) ≈N(20,4) • P(x|w2) ≈N(15,2)

  14. Full code • function likelihoodsRatios() • pw1=2/3; pw2=1/3; • mu1=20; mu2=15; • s1=4; s2=2; • x=min(mu1-4*s1,mu2-4*s2):0.1:max(mu1+4*s1,mu2+4*s2); • n=length(x); • pxw1=zeros(1,n); • pxw2=zeros(1,n); • ratio=zeros(1,n); • for i=1:n • pxw1(i)=NormalFun(x(i),mu1,s1); • pxw2(i)=NormalFun(x(i),mu2,s2); • ratio(i)=pxw1(i)/pxw2(i); • end • lamda=[1 2 ; 3 1]; • theta=((lamda(1,2)-lamda(2,2))*pw2)/((lamda(2,1)-lamda(1,1))*pw1) • plot(x,ratio,'m-',x,theta,'g-'); • axis([0 max(x) 0 3]);

  15. output

  16. H.W 4 Using the same data of the part1, modify the code of part1 to : Draw a relation between the conditional risk probability for each action Deadline: Next Lab

More Related