#include <Classifier.h>
Inheritance diagram for prapi::Classifier< T, I, C >:

Classifier modifies the testing samples by setting their classification field to a new value.
Classifier stores a pointer to the training samples and proximity measure for memory saving purposes. Take care that the training samples won't be deleted before the Classifier has done its due.
If you want to keep track of the state of the classification, you might want to add some EventListeners to a classifier. After each classified sample, all registered event listeners are notified.
The purpose of a classifier is just to set the classification for a set of samples. When you want to get more information of the classification result, use a confusion matrix for the classified sample set.
Public Methods | |
| Classifier (util::List< Sample< T, I, C > > *trainingSamples=NULL, ProximityMeasure< T > *measure=NULL, int classCount=-1) | |
| Create a new classifier. | |
| Classifier (util::List< Sample< T, I, C > > &trainingSamples, ProximityMeasure< T > *measure, int classCount) | |
| Create a new classifier. | |
| Classifier (util::List< Sample< T, I, C > > &trainingSamples, ProximityMeasure< T > &measure, int classCount) | |
| Create a new classifier. | |
| virtual | ~Classifier () |
| The Destructor of Classifier. | |
| virtual void | holdOut (util::List< Sample< T, I, C > > &lst) throw (ClassificationException&) |
| Perform a holdout test using the given samples as testing data. | |
| virtual void | leaveOneOut (void) throw (ClassificationException&) |
| Perform a leave-one-out test on the training data. | |
| virtual C | getClassification (Sample< T, I, C > &sample)=0 throw (ClassificationException&) |
| Get the classification for a single sample. | |
| virtual util::List< int > | getRanks (Sample< T, I, C > &sample) throw (ClassificationException&) |
| Sort all classes according to their proximity to a given test sample. | |
| virtual void | setTrainingSamples (util::List< Sample< T, I, C > > *lst) |
| Change the training samples held by this classifier. | |
|
util::List< Sample< T, I, C > > * | getTrainingSamples (void) |
| Get the training samples held by this classifier. | |
|
const util::List< Sample< T, I, C > > * | getTrainingSamples (void) const |
| Get the training samples held by this classifier. | |
|
util::List< Sample< T, I, C > > *& | trainingSamples (void) |
| Get the training samples held by this classifier. | |
| void | setProximityMeasure (ProximityMeasure< T > *measure) |
| Set the proximity (distance) measure used in classification. | |
| void | setProximityMeasure (ProximityMeasure< T > &measure) |
| Set the proximity (distance) measure used in classification. | |
| ProximityMeasure< T > * | getProximityMeasure (void) const |
| Get a pointer to the proximity measure. | |
| void | setClassCount (int count) |
| Set the class count for this classifier. | |
| int | getClassCount (void) const |
| Get the class count. | |
| int & | classCount (void) |
| Get the class count. | |
| void | setAutodeleteMeasure (bool del) |
| Enable or disable the automatic deletion of the proximity measure. | |
| bool | getAutodeleteMeasure (void) const |
| See whether the classifier is going to automatically delete its proximity measure. | |
| bool & | autodeleteMeasure (void) |
| Directly access the autorelease mode flag. | |
Static Public Methods | |
| util::List< Sample< T, I, C > > | selectRandomly (const util::List< Sample< T, I, C > > &samples, int n) throw (InvalidArgumentException&) |
| Randomly select n samples from samples. | |
| void | divide (const util::List< Sample< T, I, C > > &samples, util::List< Sample< T, I, C > > &correct, util::List< Sample< T, I, C > > &wrong) |
| Divide the given sample list into two disjoint sets, one containing the correctly classified samples and the other containing the rest. | |
| util::List< util::List< Sample< T, I, C > > > | divide (const util::List< Sample< T, I, C > > &samples, util::List< int > &classes) throw (ClassificationException&) |
| Divide the given sample list into disjoint sets. | |
| util::List< util::List< Sample< T, I, C > > > | divideByTrueClass (const util::List< Sample< T, I, C > > &samples, util::List< int > &classes) throw (ClassificationException&) |
| DivideByTrueClass divides a sample set according to the true class of a sample (divide(samples,classes) divides by the classification). | |
Protected Attributes | |
|
util::List< Sample< T, I, C > > * | _lstpTrainingSamples |
| A pointer to the list of training samples. | |
| ProximityMeasure< T > * | _proximityMeasure |
| A pointer to the code used to measure proximities between samples. | |
| int | _iClassCount |
| The number of classes. | |
|
||||||||||||||||||||
|
Create a new classifier.
The memory pointed by measure is automatically released upon the deletion of the classifier. Training samples are not deleted automatically. That is, you can create a Classifier like the following: MyClassifier classifier(&trainingSamples, new MyProximityMeasure, classes);One does not need to store a pointer to "new MyProximityMeasure" as the memory is released automatically.
|
|
||||||||||||||||||||
|
Create a new classifier. The memory pointed by measure is automatically released upon the deletion of the classifier. Training samples are not deleted automatically.
|
|
||||||||||||||||||||
|
Create a new classifier.
|
|
|||||||||
|
The Destructor of Classifier. If Autodelete mesure is on the measure will be deleted. |
|
||||||||||||||||
|
Divide the given sample list into disjoint sets. The number of disjoint sets depends on the number of classes given from the IntegerList classes. (Example: if classes has number 3 at the index 2, then all samples that have been classified to class 2 are added to the list index 3). Return List contain classes from 0 to max integer given in classes.
|
|
||||||||||||||||||||
|
Divide the given sample list into two disjoint sets, one containing the correctly classified samples and the other containing the rest.
|
|
||||||||||||||||
|
DivideByTrueClass divides a sample set according to the true class of a sample (divide(samples,classes) divides by the classification).
|
|
||||||||||
|
Get the classification for a single sample. This method is used by holdOut and leaveOneOut to classify each sample. Subclasses must override this method.
Implemented in prapi::NNClassifier< T, I, C >, prapi::kNNClassifier< T, I, C >, prapi::MinimumDistanceClassifier< T, I, C >, prapi::MahalanobisClassifier< T, I, C >, prapi::MultiClassifier< T, I >, and prapi::VQClassifier< I, C >. |
|
||||||||||
|
Sort all classes according to their proximity to a given test sample. The default implementation loops through all training samples and finds the closest match from each class using the internal proximity measure. It then ranks the classes according to the obtained proximities. The larger the rank, the worse the match.
|
|
||||||||||
|
Perform a holdout test using the given samples as testing data.
|
|
||||||||||||||||
|
Randomly select n samples from samples.
|
|
||||||||||
|
Enable or disable the automatic deletion of the proximity measure. You will probably not need this method, but if you do, take enormous care that memory is not released twice.
|
|
||||||||||
|
Set the class count for this classifier. The number does not actually matter for some classifiers, but you might want to keep it correct in any case. |
|
||||||||||
|
Set the proximity (distance) measure used in classification. If Classifier is initialized using a pointer to a proximity measure (autodelete mode), then the memory allocated by the old measure is automatically released. Autodelete mode will be turned off upon the exit of this method.
|
|
||||||||||
|
Set the proximity (distance) measure used in classification. If Classifier is initialized using a pointer to a proximity measure (autodelete mode), then the memory allocated by the old measure is automatically released. Autodelete mode will be turned on upon the exit of this method.
|
|
||||||||||
|
Change the training samples held by this classifier.
Reimplemented in prapi::MinimumDistanceClassifier< T, I, C >, and prapi::MahalanobisClassifier< T, I, C >. |