This code sets up a plot of the data such that the

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: represent a 3 are red. See t t e il (http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/title.html) and l g n eed (http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/legend.html) for information on adding the title and legend. Before using c a s f (http://www.mathworks.com/access/helpdesk/help/toolbox/stats/index.html?/access/helpdesk/help/toolbox/stats/classify.html) we can set up a lsiy vector that contains the actual labels for our data, to train the classification algorithm. If we don't know the labels for the data, then the element in the g o pvector ru should be an empty string or N N (See grouping data a. (http://www.mathworks.com/access/helpdesk/help/toolbox/stats/index.html?/access/helpdesk/help/toolbox/stats/bqziops.html) for more information.) > gop=oe(0,) > ru ns401; > gop2140 =2 > ru(0:0) ; We can now classify our data. > [ls,err PSEIR lg,cef =casf(ape sml,gop 'ier) > cas ro, OTRO, op of] lsiysml, ape ru, lna'; The full details of this line can be examined in the Matlab help file linked above. What we care about are c a s which contains the labels that the algorithm thinks that ls, each data point belongs to, and c e f which contains information about the line that algorithm created to separate the data into each class. of, We can see the efficacy of the algorithm by comparing c a sto g o p ls ru. > sm(ls=gop >u cas=ru) as= n 39 6 This compares the value in c a sto the value in g o p The answer of 369 tells us that the algorithm correctly determined the class of the point 369 times, out of a ls ru. possible 400 data points. This gives us an empirical error rat e of 0.0775. We can see the line produced by LDA using c e f of. > k=cef12.os; > of(,)cnt > l=cef12.ier > of(,)lna; > f=srnf' =%+gx%*' k l1,l2) > pit(0 g%*+gy, , () (); > epo(,[i(ape:1) mxsml(,),mnsml(,),mxsml(,)]; > zltf mnsml(,), a(ape:1) i(ape:2) a(ape:2)) wikicour senote.com/w/index.php?title= Stat841&pr intable= yes 12/74 10/09/2013...
View Full Document

Ask a homework question - tutors are online