SOM Toolbox Online documentation http://www.cis.hut.fi/projects/somtoolbox/

knn_old

[Class,P]=knn_old(Data, Proto, proto_class, K)

KNN_OLD A K-nearest neighbor classifier using Euclidean distance 

 [Class,P]=knn_old(Data, Proto, proto_class, K)

  [sM_class,P]=knn_old(sM, sData, [], 3);
  [sD_class,P]=knn_old(sD, sM, class);
  [class,P]=knn_old(data, proto, class);
  [class,P]=knn_old(sData, sM, class,5);

  Input and output arguments ([]'s are optional): 
   Data   (matrix) size Nxd, vectors to be classified (=classifiees)
          (struct) map or data struct: map codebook vectors or
                   data vectors are considered as classifiees.
   Proto  (matrix) size Mxd, prototype vector matrix (=prototypes)
          (struct) map or data struct: map codebook vectors or
                   data vectors are considered as prototypes.
   [proto_class] (vector) size Nx1, integers 1,2,...,k indicating the
                   classes of corresponding protoptypes, default: see the 
                   explanation below. 
   [K]    (scalar) the K in KNN classifier, default is 1
 
   Class  (matrix) size Nx1, vector of 1,2, ..., k indicating the class 
                   desicion according to the KNN rule
   P      (matrix) size Nxk, the relative amount of prototypes of 
                   each class among the K closest prototypes for
                   each classifiee.

 If 'proto_class' is _not_ given, 'Proto' _must_ be a labeled SOM
 Toolbox struct. The label of the data vector or the first label of
 the map model vector is considered as class label for th prototype
 vector. In this case the output 'Class' is a copy of 'Data' (map or
 data struct) relabeled according to the classification.  If input
 argument 'proto_class' _is_ given, the output argument 'Class' is
 _always_ a vector of integers 1,2,...,k indiacating the class.

 If there is a tie between representatives of two or more classes
 among the K closest neighbors to the classifiee, the class is
 selected randomly among these candidates.

 IMPORTANT
 
 ** Even if prototype vectors are given in a map struct the mask _is not 
    taken into account_ when calculating Euclidean distance
 ** The function calculates the total distance matrix between all
    classifiees and prototype vectors. This results to an MxN matrix; 
    if N is high it is recommended to divide the matrix 'Data'
    (the classifiees) into smaller sets in order to avoid memory
    overflow or swapping. Also, if K>1 this function uses 'sort' which is
    considerably slower than 'max' which is used for K==1.

 See also KNN, SOM_LABEL, SOM_AUTOLABEL



[ SOM Toolbox online doc ]