KSquare Utilities
FeatureFileIOSparse.h
Go to the documentation of this file.
1 #ifndef _FEATUREFILEIOSPARSE_
2 #define _FEATUREFILEIOSPARSE_
3 
4 #include "FeatureFileIO.h"
5 
6 
7 namespace KKMLL
8 {
9 
10  /**
11  @brief Supports the reading and writing of Sparse feature files similar to the ones libSVM use.
12  @details
13  @code
14  * *************************************************************************************************
15  * * FeatureFileIOSparse Sub-classed from FeatureFileIO. It supports the reading and writing *
16  * * of Sparse Files as used by the libSVM. *
17  * * *
18  * * One example per row. *
19  * * any row that starts with '//' is ignored. *
20  * * On each row there will be several fields separated by the space(' ') character. The first *
21  * * field will be the class name followed by the attribute data. *
22  * * *
23  * * - First Field is the Class Name. This differers from libSVM which assumes that class-names *
24  * * are integers. We support alpha numeric class names. *
25  * * - Attribute Fields will be of the following format. <FeatureNum>:<Feature value>. *
26  * * *
27  * * ex: *
28  * * "0 0:12.12 4:87.1242 12:-65.63 15:0.872" *
29  * * "1 2:-76.92 12:65.882 26:76" *
30  * * "1 1:28.74 3:8.452 11:22.72" *
31  * * *
32  * *************************************************************************************************
33  @endcode
34  @see FeatureFileIO
35  */
37  {
38  public:
41 
43 
44  static FeatureFileIOSparsePtr Driver () {return &driver;}
45 
46 
47  virtual FileDescPtr GetFileDesc (const KKStr& _fileName,
48  istream& _in,
49  MLClassListPtr _classList,
50  kkint32& _estSize,
51  KKStr& _errorMessage,
52  RunLog& _log
53  );
54 
55 
56  virtual FeatureVectorListPtr LoadFile (const KKStr& _fileName,
57  const FileDescPtr _fileDesc,
58  MLClassList& _classes,
59  istream& _in,
60  kkint32 _maxCount, // Maximum # images to load.
61  VolConstBool& _cancelFlag,
62  bool& _changesMade,
63  KKStr& _errorMessage,
64  RunLog& _log
65  );
66 
67 
68  virtual void SaveFile (FeatureVectorList& _data,
69  const KKStr& _fileName,
70  FeatureNumListConst& _selFeatures,
71  ostream& _out,
72  kkuint32& _numExamplesWritten,
73  VolConstBool& _cancelFlag,
74  bool& _successful,
75  KKStr& _errorMessage,
76  RunLog& _log
77  );
78 
79 
80 
81  private:
82  static FeatureFileIOSparse driver;
83 
84  }; /* FeatureFileIOSparse */
85 
86 } /* namespace KKMLL */
87 
88 #endif
virtual void SaveFile(FeatureVectorList &_data, const KKStr &_fileName, FeatureNumListConst &_selFeatures, ostream &_out, kkuint32 &_numExamplesWritten, VolConstBool &_cancelFlag, bool &_successful, KKStr &_errorMessage, RunLog &_log)
__int32 kkint32
Definition: KKBaseTypes.h:88
virtual FileDescPtr GetFileDesc(const KKStr &_fileName, istream &_in, MLClassListPtr _classList, kkint32 &_estSize, KKStr &_errorMessage, RunLog &_log)
FeatureNumList const FeatureNumListConst
FeatureFileIOSparse * FeatureFileIOSparsePtr
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
Container class for FeatureVector derived objects.
virtual FeatureVectorListPtr LoadFile(const KKStr &_fileName, const FileDescPtr _fileDesc, MLClassList &_classes, istream &_in, kkint32 _maxCount, VolConstBool &_cancelFlag, bool &_changesMade, KKStr &_errorMessage, RunLog &_log)
Base class for all FeatureFileIO classes.
Definition: FeatureFileIO.h:48
static KKStr Concat(const std::vector< std::string > &values)
Concatenates the list of &#39;std::string&#39; strings.
Definition: KKStr.cpp:1082
FileDesc * FileDescPtr
Used for logging messages.
Definition: RunLog.h:49
void EncodeProblem(const struct svm_paramater &param, struct svm_problem &prob_in, struct svm_problem &prob_out)
MLClassList * MLClassListPtr
Definition: MLClass.h:49
Supports the reading and writing of Sparse feature files similar to the ones libSVM use...
Maintains a list of MLClass instances.
Definition: MLClass.h:233
static FeatureFileIOSparsePtr Driver()
volatile const bool VolConstBool
Definition: KKBaseTypes.h:163