|
@@ -0,0 +1,87 @@
|
|
|
+/**
|
|
|
+* @file testClassifier.cpp
|
|
|
+* @brief main program for classifier evaluation
|
|
|
+* @author Erik Rodner
|
|
|
+* @date 2007-10-12
|
|
|
+*/
|
|
|
+
|
|
|
+#include <objrec/nice_nonvis.h>
|
|
|
+
|
|
|
+#include <fstream>
|
|
|
+#include <iostream>
|
|
|
+
|
|
|
+#include <objrec/cbaselib/MultiDataset.h>
|
|
|
+#include <objrec/iclassifier/icgeneric/CSGeneric.h>
|
|
|
+#include <objrec/cbaselib/ClassificationResults.h>
|
|
|
+#include <objrec/iclassifier/codebook/MutualInformation.h>
|
|
|
+
|
|
|
+#include "objrec/classifier/classifierbase/FeaturePoolClassifier.h"
|
|
|
+#include <objrec/classifier/fpclassifier/randomforest/FPCRandomForestTransfer.h>
|
|
|
+#include <objrec/classifier/classifierinterfaces/VCFeaturePool.h>
|
|
|
+
|
|
|
+#include <objrec/baselib/Config.h>
|
|
|
+#include <objrec/baselib/Preprocess.h>
|
|
|
+#include <objrec/baselib/StringTools.h>
|
|
|
+
|
|
|
+#undef DEBUG
|
|
|
+
|
|
|
+using namespace OBJREC;
|
|
|
+
|
|
|
+using namespace NICE;
|
|
|
+using namespace std;
|
|
|
+
|
|
|
+int main (int argc, char **argv)
|
|
|
+{
|
|
|
+ std::set_terminate(__gnu_cxx::__verbose_terminate_handler);
|
|
|
+
|
|
|
+ Config conf ( argc, argv );
|
|
|
+ string fn = conf.gS("main", "input", "train.vec");
|
|
|
+ int format = conf.gI("main", "format", 0 );
|
|
|
+ string outfn = conf.gS("main", "output", "out.vec");
|
|
|
+ int dim = conf.gI("main", "dim", 0);
|
|
|
+
|
|
|
+ ifstream fin(fn.c_str(), ifstream::in);
|
|
|
+
|
|
|
+ LabeledSetVector test;
|
|
|
+ vector<double> maxv(dim,numeric_limits<double>::min());
|
|
|
+ vector<double> minv(dim,numeric_limits<double>::max());
|
|
|
+
|
|
|
+ while(fin.good())
|
|
|
+ {
|
|
|
+ Vector tmp(dim);
|
|
|
+ for(int i = 0; i < dim; i++)
|
|
|
+ {
|
|
|
+ fin >> tmp[i];
|
|
|
+ maxv[i] = std::max(maxv[i],tmp[i]);
|
|
|
+ minv[i] = std::min(minv[i],tmp[i]);
|
|
|
+ }
|
|
|
+ int label;
|
|
|
+ fin >> label;
|
|
|
+ label--;
|
|
|
+ if(label > 5)
|
|
|
+ label--;
|
|
|
+ test.add(label, tmp);
|
|
|
+ }
|
|
|
+
|
|
|
+ for(int i = 0; i < dim; i++)
|
|
|
+ {
|
|
|
+ maxv[i] -= minv[i];
|
|
|
+ }
|
|
|
+
|
|
|
+ for( map< int, vector<NICE::Vector *> >::iterator iter = test.begin(); iter != test.end(); ++iter )
|
|
|
+ {
|
|
|
+ for(int j = 0; j < iter->second.size(); j++)
|
|
|
+ {
|
|
|
+ for(int i = 0; i < iter->second[j]->size(); i++)
|
|
|
+ {
|
|
|
+ (*(iter->second[j]))[i] = ((*(iter->second[j]))[i] - minv[i]) / maxv[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ test.save(outfn);
|
|
|
+ fin.close();
|
|
|
+
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|