X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=classifier.h;fp=classifier.h;h=b5dc2a72fd397eab3f213d5c602171e830928b07;hb=d922ad61d35e9a6996730bec24b16f8bf7bc426c;hp=0000000000000000000000000000000000000000;hpb=3bb118f5a9462d02ff7d99ef28ecc0d7e23529f9;p=folded-ctf.git diff --git a/classifier.h b/classifier.h new file mode 100644 index 0000000..b5dc2a7 --- /dev/null +++ b/classifier.h @@ -0,0 +1,61 @@ + +/////////////////////////////////////////////////////////////////////////// +// This program is free software: you can redistribute it and/or modify // +// it under the terms of the version 3 of the GNU General Public License // +// as published by the Free Software Foundation. // +// // +// This program is distributed in the hope that it will be useful, but // +// WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // +// General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +// // +// Written by Francois Fleuret, (C) IDIAP // +// Contact for comments & bug reports // +/////////////////////////////////////////////////////////////////////////// + +/* + + This class is mostly able to learn a classifier from a SampleSet and + to provide a scalar response on any test sample. Additional methods + are required for persistence and select the possibly very few used + features. + +*/ + +#ifndef CLASSIFIER_H +#define CLASSIFIER_H + +#include "storable.h" +#include "pi_feature_family.h" +#include "sample_set.h" +#include "pose_cell_hierarchy.h" +#include "labelled_image_pool.h" +#include "loss_machine.h" + +class Classifier : public Storable { +public: + virtual ~Classifier(); + + // Evaluate on a sample + virtual scalar_t response(SampleSet *sample_set, int n_sample) = 0; + + // Train the classifier + virtual void train(LossMachine *loss_machine, SampleSet *train, scalar_t *response) = 0; + + // Tag in the boolean array which features are actually used + virtual void tag_used_features(bool *used) = 0; + // Change the indexes of the used features + virtual void re_index_features(int *new_indexes) = 0; + + // Storage + virtual void read(istream *is) = 0; + virtual void write(ostream *os) = 0; + + void extract_pi_feature_family(PiFeatureFamily *full_pi_feature_family, + PiFeatureFamily *extracted_pi_feature_family); +}; + +#endif