Mercurial > hg > camir-aes2014
annotate toolboxes/FullBNT-1.0.7/netlab3.3/knn.m @ 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 function net = knn(nin, nout, k, tr_in, tr_targets) |
wolffd@0 | 2 %KNN Creates a K-nearest-neighbour classifier. |
wolffd@0 | 3 % |
wolffd@0 | 4 % Description |
wolffd@0 | 5 % NET = KNN(NIN, NOUT, K, TR_IN, TR_TARGETS) creates a KNN model NET |
wolffd@0 | 6 % with input dimension NIN, output dimension NOUT and K neighbours. |
wolffd@0 | 7 % The training data is also stored in the data structure and the |
wolffd@0 | 8 % targets are assumed to be using a 1-of-N coding. |
wolffd@0 | 9 % |
wolffd@0 | 10 % The fields in NET are |
wolffd@0 | 11 % type = 'knn' |
wolffd@0 | 12 % nin = number of inputs |
wolffd@0 | 13 % nout = number of outputs |
wolffd@0 | 14 % tr_in = training input data |
wolffd@0 | 15 % tr_targets = training target data |
wolffd@0 | 16 % |
wolffd@0 | 17 % See also |
wolffd@0 | 18 % KMEANS, KNNFWD |
wolffd@0 | 19 % |
wolffd@0 | 20 |
wolffd@0 | 21 % Copyright (c) Ian T Nabney (1996-2001) |
wolffd@0 | 22 |
wolffd@0 | 23 |
wolffd@0 | 24 net.type = 'knn'; |
wolffd@0 | 25 net.nin = nin; |
wolffd@0 | 26 net.nout = nout; |
wolffd@0 | 27 net.k = k; |
wolffd@0 | 28 errstring = consist(net, 'knn', tr_in, tr_targets); |
wolffd@0 | 29 if ~isempty(errstring) |
wolffd@0 | 30 error(errstring); |
wolffd@0 | 31 end |
wolffd@0 | 32 net.tr_in = tr_in; |
wolffd@0 | 33 net.tr_targets = tr_targets; |
wolffd@0 | 34 |