annotate toolboxes/FullBNT-1.0.7/nethelp3.3/knnfwd.htm @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 <html>
wolffd@0 2 <head>
wolffd@0 3 <title>
wolffd@0 4 Netlab Reference Manual knnfwd
wolffd@0 5 </title>
wolffd@0 6 </head>
wolffd@0 7 <body>
wolffd@0 8 <H1> knnfwd
wolffd@0 9 </H1>
wolffd@0 10 <h2>
wolffd@0 11 Purpose
wolffd@0 12 </h2>
wolffd@0 13 Forward propagation through a K-nearest-neighbour classifier.
wolffd@0 14
wolffd@0 15 <p><h2>
wolffd@0 16 Synopsis
wolffd@0 17 </h2>
wolffd@0 18 <PRE>
wolffd@0 19
wolffd@0 20 [y, l] = knnfwd(net, x)
wolffd@0 21 </PRE>
wolffd@0 22
wolffd@0 23
wolffd@0 24 <p><h2>
wolffd@0 25 Description
wolffd@0 26 </h2>
wolffd@0 27 <CODE>[y, l] = knnfwd(net, x)</CODE> takes a matrix <CODE>x</CODE>
wolffd@0 28 of input vectors (one vector per row)
wolffd@0 29 and uses the <CODE>k</CODE>-nearest-neighbour rule on the training data contained
wolffd@0 30 in <CODE>net</CODE> to
wolffd@0 31 produce
wolffd@0 32 a matrix <CODE>y</CODE> of outputs and a matrix <CODE>l</CODE> of classification
wolffd@0 33 labels.
wolffd@0 34 The nearest neighbours are determined using Euclidean distance.
wolffd@0 35 The <CODE>ij</CODE>th entry of <CODE>y</CODE> counts the number of occurrences that
wolffd@0 36 an example from class <CODE>j</CODE> is among the <CODE>k</CODE> closest training
wolffd@0 37 examples to example <CODE>i</CODE> from <CODE>x</CODE>.
wolffd@0 38 The matrix <CODE>l</CODE> contains the predicted class labels
wolffd@0 39 as an index 1..N, not as 1-of-N coding.
wolffd@0 40
wolffd@0 41 <p><h2>
wolffd@0 42 Example
wolffd@0 43 </h2>
wolffd@0 44 <PRE>
wolffd@0 45
wolffd@0 46 net = knn(size(xtrain, 2), size(t_train, 2), 3, xtrain, t_train);
wolffd@0 47 y = knnfwd(net, xtest);
wolffd@0 48 conffig(y, t_test);
wolffd@0 49 </PRE>
wolffd@0 50
wolffd@0 51 Creates a 3 nearest neighbour model <CODE>net</CODE> and then applies it to
wolffd@0 52 the data <CODE>xtest</CODE>. The results are plotted as a confusion matrix with
wolffd@0 53 <CODE>conffig</CODE>.
wolffd@0 54
wolffd@0 55 <p><h2>
wolffd@0 56 See Also
wolffd@0 57 </h2>
wolffd@0 58 <CODE><a href="kmeans.htm">kmeans</a></CODE>, <CODE><a href="knn.htm">knn</a></CODE><hr>
wolffd@0 59 <b>Pages:</b>
wolffd@0 60 <a href="index.htm">Index</a>
wolffd@0 61 <hr>
wolffd@0 62 <p>Copyright (c) Ian T Nabney (1996-9)
wolffd@0 63
wolffd@0 64
wolffd@0 65 </body>
wolffd@0 66 </html>