Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

TrainDataSrcFeatureTable.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Training_TrainDataSrcFeatureTable_h
00002 #define Impala_Core_Training_TrainDataSrcFeatureTable_h
00003 
00004 #include "Core/Training/TrainDataSrc.h"
00005 #include "Core/Training/SvmProblemBuilder.h"
00006 #include "Core/Feature/FeatureTable.h"
00007 #include "Link/Svm/LinkSvm.h"
00008 
00009 namespace Impala
00010 {
00011 namespace Core
00012 {
00013 namespace Training
00014 {
00015 
00016 class TrainDataSrcFeatureTable : public TrainDataSrc
00017 {
00018 public:
00019     typedef Core::Vector::VectorTem<Real64> VectorReal64;
00020 
00021     TrainDataSrcFeatureTable(Table::AnnotationTable* annotation,
00022                              Feature::FeatureTable* features)
00023         : TrainDataSrc(annotation)
00024     {
00025         mFeatures = features;
00026         mVectorLength = mFeatures->GetFeatureVectorLength();
00027     }
00028 
00029     virtual
00030     ~TrainDataSrcFeatureTable()
00031     {
00032     }
00033 
00038     virtual svm_problem*
00039     MakeSvmProblem()
00040     {
00041         SvmProblemBuilder pb(mAnnotation, mSelection);
00042         pb.AddFeatureTable(mFeatures);
00043         return pb.MakeProblem();
00044     }
00045 
00046     virtual svm_problem*
00047     MakeSvmProblem(int i)
00048     {
00049         if(i >= mFeatures->Size())
00050         {
00051             ILOG_ERROR("index > mFeatures->Size: " << i);
00052             return MakeEmptyProblem();
00053         }
00054         Quid q = mFeatures->Get1(i);
00055         VectorReal64 vector = mFeatures->Get2(i);
00056         SvmProblemBuilder pb(mAnnotation, mSelection);
00057         svm_problem* ret = pb.MakeProblem(&vector);
00058         return ret;
00059     }
00060 
00061     // copy from file TrainDataSrcFeature...
00062     virtual void
00063     FreeProblem(svm_problem* p)
00064     {
00065         delete[] p->y;
00066         for(int i=0 ; i<p->l ; ++i)
00067             delete[] p->x[i];
00068         delete[] p->x;
00069         delete p;
00070     }
00071 
00072     virtual int
00073     GetVectorLength()
00074     {
00075         return mVectorLength;
00076     }
00077 
00078     virtual int
00079     Size()
00080     {
00081         ILOG_DEBUG("correct Size called");
00082         return mFeatures->Size();
00083     }
00084 
00085     virtual Quid
00086     GetQuid(int i)
00087     {
00088         ILOG_DEBUG("correct GetQuid called");
00089         return mFeatures->Get1(i);
00090     }
00091 
00092 private:
00093     Feature::FeatureTable* mFeatures;
00094     int mVectorLength;
00095 
00096     ILOG_VAR_DECL;
00097 };
00098 
00099 ILOG_VAR_INIT(TrainDataSrcFeatureTable, Impala.Core.Training);
00100 
00101 }//namespace Training
00102 }//namespace Core
00103 }//namespace Impala
00104 
00105 
00106 #endif

Generated on Fri Mar 19 09:31:25 2010 for ImpalaSrc by  doxygen 1.5.1