#ifndef _classifier_
#define _classifier_
/*
classifier
This is the main program. It reads the data and calls the NN classifier, and
also provides common functions for the classifiers to store the k-NN neighbors,
voting and printing the results.
*/
#ifndef REAL
#define REAL double
#endif
extern int ComputeKNN;
/* possible values:
1 - obtains exactly the k-NN, and classifies the sample with them
0 - uses the k-NSN rule for classification, see the following references
for more details:
@article {
author = "Moreno-Seco, F.;Micó, L.;Oncina j.",
title = "Extending fast nearest neighbour search algorithms for approximate k-NN classification",
journal = "Lecture Notes in Computer Science - Lecture Notes in Artificial Intelligence",
pages = "589-597",
volume = "2652",
year = "2003"
}
@inproceedings {
author = "Moreno-Seco, F.; Micó, L.; Oncina, J",
title = "A new classification rule based on nearest neighbour search",
address = "Cambridge",
booktitle = "Proceedings of the 17 International Conference on Pattern recognition 2004",
pages = "408-411",
year = "2004"
}
*/
REAL StoreNN(int nneigh,int *vNN,REAL *vdist,int *vclass,
REAL dist,int cnn,int theclass);
/* stores the candidate to NN 'cnn' (with distance 'dist' and class 'theclass')
in the vector that holds the k-NN (if possible).
The return value is the distance to the last element in that vector (if
ComputeKNN==1), or the distance to the nearest neighbor (if ComputeKNN==0).
This is the distance used to bound the search the training set.
*/
int MostVotedClass(int nclasses,int nneigh,int *vclass,int *vNN,REAL *vdist);
/* returns the most voted class among the classes of the k-NN. If there is
an even and option -breven is activated, the process is repeated eliminating
the last neighbor (until there is only one neighbor); otherwise the class
appearing first in the file is the one selected when there is an even. In
practice there are few evens and do have a minor effect in error rates.
*/
void ShowResults(int fromK,int toK,int iK,int *error,
int *distances,int nptest);
/* shows the results of the classification of the test set: for each value of
k, it shows the average error rate (over all the prototypes in the test set)
and the average number of distance computations.
*/
#endif