Просмотр исходного кода

everything should be ready, but we got an error while linking

Alexander Luetz 13 лет назад
Родитель
Сommit
60f967f724

+ 1 - 1
classifier/kernelclassifier/KCGPApproxOneClass.cpp

@@ -12,7 +12,7 @@
 #include "core/vector/Algorithms.h"
 #include "core/vector/VVector.h"
 
-#include "vislearning/classifier/kernelclassifier/KCGPApproxOneClass.h"
+#include "KCGPApproxOneClass.h"
 
 
 using namespace std;

+ 1 - 5
classifier/kernelclassifier/KCGPApproxOneClass.h

@@ -13,9 +13,6 @@
 #include "vislearning/classifier/classifierbase/KernelClassifier.h"
 
 #include "vislearning/math/kernels/Kernel.h"
-#include "vislearning/math/kernels/ParameterizedKernel.h"
-
-#include "vislearning/regression/regressionbase/RegressionAlgorithmKernel.h"
 
 
 #define VARIANCE_DETECTION_MODE 1
@@ -51,7 +48,6 @@ class KCGPApproxOneClass : public KernelClassifier
     
   /** classify an example by using its kernel values with the training set,
     be careful with the order in @param kernelVector */
-//   ClassificationResult classifyKernel ( const NICE::Vector & kernelVector, double kernelSelf ) const;
   virtual ClassificationResult classifyKernel ( const NICE::Vector & kernelVector, double kernelSelf ) const;
    
     /** clone this object */
@@ -60,7 +56,7 @@ class KCGPApproxOneClass : public KernelClassifier
   void restore(std::istream&, int);
   void store(std::ostream&, int) const;
   void clear(){};
-  
+
 };
 
 

+ 36 - 34
progs/testImageNetBinary.cpp

@@ -14,8 +14,9 @@
 #include "fast-hik/MatFileIO.h"
 #include "fast-hik/ImageNetData.h"
 
-#include "vislearning/classifier/kernelclassifier/KCGPApproxOneClass.h"
 #include "vislearning/classifier/kernelclassifier/KCGPOneClass.h"
+#include "vislearning/classifier/kernelclassifier/KCGPApproxOneClass.h"
+
 
 #include "vislearning/math/kernels/KernelData.h"
 #include "vislearning/math/kernels/Kernel.h"
@@ -54,7 +55,9 @@ int main (int argc, char **argv)
 
   ImageNetData imageNet ( imageNetPath + "demo/" );
 
-  imageNet.getBatchData ( data, y, "train", "training" );
+//   imageNet.getBatchData ( data, y, "train", "training" );
+  LabeledSetVector train;
+  imageNet.loadDataAsLabeledSetVector( train );
   
   //set up the kernel function
   double rbf_sigma = conf.gD("main", "rbf_sigma", -2.0 );
@@ -76,38 +79,37 @@ int main (int argc, char **argv)
     classifier = new KCGPApproxOneClass ( &conf, &kernelFunction );
   }
   //and perform the training
-  //TODO how do we get a LabelSetSelection-Object out of our matlab data struct?
-//   classifier->teach( train );    
-
-  uint n = y.size();
-  
-  set<int> positives;
-  set<int> negatives;
-
-  map< int, set<int> > mysets;
-  for ( uint i = 0 ; i < n; i++ )
-    mysets[ y[i] ].insert ( i );
-
-  if ( mysets[ positiveClass ].size() == 0 ) 
-    fthrow(Exception, "Class " << positiveClass << " is not available.");
-
-  // add our positive examples
-  for ( set<int>::const_iterator i = mysets[positiveClass].begin(); i != mysets[positiveClass].end(); i++ )
-    positives.insert ( *i );
-
-  int Nneg = conf.gI("main", "nneg", 1 );
-  for ( map<int, set<int> >::const_iterator k = mysets.begin(); k != mysets.end(); k++ )
-  {
-    int classno = k->first;
-    if ( classno == positiveClass )
-      continue;
-    const set<int> & s = k->second;
-    uint ind = 0;
-    for ( set<int>::const_iterator i = s.begin(); (i != s.end() && ind < Nneg); i++,ind++  )
-      negatives.insert ( *i );
-  }
-  std::cerr << "Number of positive examples: " << positives.size() << std::endl;
-  std::cerr << "Number of negative examples: " << negatives.size() << std::endl;
+  classifier->teach( train );    
+
+//   uint n = y.size();
+//   
+//   set<int> positives;
+//   set<int> negatives;
+// 
+//   map< int, set<int> > mysets;
+//   for ( uint i = 0 ; i < n; i++ )
+//     mysets[ y[i] ].insert ( i );
+// 
+//   if ( mysets[ positiveClass ].size() == 0 ) 
+//     fthrow(Exception, "Class " << positiveClass << " is not available.");
+// 
+//   // add our positive examples
+//   for ( set<int>::const_iterator i = mysets[positiveClass].begin(); i != mysets[positiveClass].end(); i++ )
+//     positives.insert ( *i );
+// 
+//   int Nneg = conf.gI("main", "nneg", 1 );
+//   for ( map<int, set<int> >::const_iterator k = mysets.begin(); k != mysets.end(); k++ )
+//   {
+//     int classno = k->first;
+//     if ( classno == positiveClass )
+//       continue;
+//     const set<int> & s = k->second;
+//     uint ind = 0;
+//     for ( set<int>::const_iterator i = s.begin(); (i != s.end() && ind < Nneg); i++,ind++  )
+//       negatives.insert ( *i );
+//   }
+//   std::cerr << "Number of positive examples: " << positives.size() << std::endl;
+//   std::cerr << "Number of negative examples: " << negatives.size() << std::endl;
 
   // ------------------------------ TESTING ------------------------------