wolffd@0: function net = knn(nin, nout, k, tr_in, tr_targets) wolffd@0: %KNN Creates a K-nearest-neighbour classifier. wolffd@0: % wolffd@0: % Description wolffd@0: % NET = KNN(NIN, NOUT, K, TR_IN, TR_TARGETS) creates a KNN model NET wolffd@0: % with input dimension NIN, output dimension NOUT and K neighbours. wolffd@0: % The training data is also stored in the data structure and the wolffd@0: % targets are assumed to be using a 1-of-N coding. wolffd@0: % wolffd@0: % The fields in NET are wolffd@0: % type = 'knn' wolffd@0: % nin = number of inputs wolffd@0: % nout = number of outputs wolffd@0: % tr_in = training input data wolffd@0: % tr_targets = training target data wolffd@0: % wolffd@0: % See also wolffd@0: % KMEANS, KNNFWD wolffd@0: % wolffd@0: wolffd@0: % Copyright (c) Ian T Nabney (1996-2001) wolffd@0: wolffd@0: wolffd@0: net.type = 'knn'; wolffd@0: net.nin = nin; wolffd@0: net.nout = nout; wolffd@0: net.k = k; wolffd@0: errstring = consist(net, 'knn', tr_in, tr_targets); wolffd@0: if ~isempty(errstring) wolffd@0: error(errstring); wolffd@0: end wolffd@0: net.tr_in = tr_in; wolffd@0: net.tr_targets = tr_targets; wolffd@0: