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