• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Jun 17th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. %obsluga elementow nietypowych
2. %klasteryzacja
3. %klasyfikacja
4. %metoda bayesa iris from uci maschine learning
5. clear;clc;
7. lab=findgroups(species);
8. d1=3;
9. d2=4;
10. gscatter(meas(:,d1),meas(:,d2),lab);
11. n=length(lab);
12. ratio=.2;
13. an=ratio*n;
14. bn=n-an;
15. aidx=randperm(n,an);
16. bidx=setdiff(1:n,aidx);
18. bdata=meas(bidx,:);%etykiety
19. alab=lab(aidx);
20. blab=lab(bidx);
21. lab2=lab;
22. lab2(bidx)=lab2(bidx)+3;
23. gscatter(meas(:,d1),meas(:,d2),lab2);
24. %korzystamy  z klasyfikatora bayes w celu klasyfikacji
25. for j=1:3
28.     pc(j)=sum(alab==j)/an;
29. end
30. for j=1:3
31.     for i=1:bn
32.         P(i,j)=pc(j)*mvnpdf(bdata(i,:),mu(j,:),sigma(j,:));
33.     end
34. end
35. [~,reslab]=max(P,[],2);
36. skutecznosc=sum(blab==reslab)/bn;
37. %klasyfikacja
38. X=linspace(min(meas(:,d1)),max(meas(:,d1)),100);
39. Y=linspace(min(meas(:,d2)),max(meas(:,d2)),100);
40. [gx,gy]=meshgrid(X,Y);
41. for j=1:3
42.     gp(:,j)=pc(j)*mvnpdf([gx(:),gy(:)],mu(j,[d1,d2]),sigma(j,[d1,d2]));
43. end
44. [~,glab]=max(gp,[],2);
45. gscatter(gx(:),gy(:),glab);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Not a member of Pastebin yet?