automatic commit
[folded-ctf.git] / classifier.h
diff --git a/classifier.h b/classifier.h
new file mode 100644 (file)
index 0000000..b5dc2a7
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.  //
+//                                                                       //
+// Written by Francois Fleuret, (C) IDIAP                                //
+// Contact <francois.fleuret@idiap.ch> 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