25 using namespace KKMLL;
54 _log.Level (20) <<
"FeatureFileIOColumn::GetFileDesc FileName[" << _fileName <<
"]" << endl;
69 while ((!eol) && (!eof))
91 while ((!eol) && (!eof))
97 if (numOfExamples != _estSize)
100 _errorMessage <<
"Row[" << rowNum <<
"] missing columns; Expected[" << _estSize <<
"] found[" << numOfExamples <<
"]";
101 _log.Level (-1) << endl << endl << endl
102 <<
"ReadColumnFile *** Invalid Row in File[" << _fileName <<
"]" << endl
103 <<
" Row [" << rowNum <<
"]" << endl
104 <<
" Num Examples[" << numOfExamples <<
"]" << endl
105 <<
" Not Match Header Row[" << _estSize <<
"]" << endl
134 KKStr& _errorMessage,
138 _log.Level (20) <<
"FeatureFileIOColumn::LoadFile FileName[" << _fileName <<
"]" << endl;
161 while ((!eof) && (!eol))
182 if (featureNum >= numOfFeatures)
186 _errorMessage <<
"Line more rows that there are supposed to be features.";
187 _log.Level (-1) << endl << endl << endl
188 <<
"FeatureFileIOColumn::LoadFile ***ERROR***" << endl
190 <<
" FileName [" << _fileName <<
"]" << endl
191 <<
" Line Num [" << featureNum <<
"]" << endl
192 <<
" Error [" <<
"Number of rows exceed number of features." <<
"]" << endl
200 while ((!eof) && (!eol))
202 if (lineNum >= lineCount)
207 _errorMessage <<
"Line[" << featureNum <<
"] More columns than there are supposed to be examples.";
208 _log.Level (-1) << endl << endl << endl
209 <<
"FeatureFileIOColumn::LoadFile ***ERROR***" << endl
211 <<
" FileName [" << _fileName <<
"]" << endl
212 <<
" Line Num [" << lineNum <<
"]" << endl
213 <<
" Error [" <<
"Number of columns exceeds number of examples defined in first row." <<
"]" << endl
219 FeatureVectorPtr example = examples->IdxToPtr (lineNum);
220 example->AddFeatureData (featureNum,
float (atof (field.Str ())));
238 const KKStr& _fileName,
244 KKStr& _errorMessage,
248 _log.Level (20) <<
"FeatureFileIOColumn::SaveFile FileName[" << _fileName <<
"]." << endl;
249 kkint32 p = (kkint32)_out.precision ();
259 while (lineNum < _data.QueueSize ())
263 _out << _data[lineNum].MLClassName ();
273 FeatureVectorList::const_iterator idx2 = _data.begin ();
275 _out << (*idx2)->FeatureData (featureNum);
276 while (idx2 != _data.end ())
278 _out <<
"\t" << (*idx2)->FeatureData (featureNum);
284 _numExamplesWritten = (kkuint32)((
double)(_data.QueueSize ()) * ((
double)featureNum / (
double)(fileDesc->NumOfFields ())));
void ExampleFileName(const KKStr &_exampleFileName)
Name of source of feature vector, ex: file name of image that the feature vector was computed from...
void PushOnBack(FeatureVectorPtr image)
Overloading the PushOnBack function in KKQueue so we can monitor the Version and Sort Order...
void GetToken(std::istream &_in, const char *_delimiters, KKStr &_token, bool &_eof, bool &_eol)
Will retrieve the next token from the input stream.
virtual void SaveFile(FeatureVectorList &_data, const KKStr &_fileName, FeatureNumListConst &_selFeatures, ostream &_out, kkuint32 &_numExamplesWritten, VolConstBool &_cancelFlag, bool &_successful, KKStr &_errorMessage, RunLog &_log)
Provides a detailed description of the attributes of a dataset.
kkuint32 NumOfFields() const
void AddAAttribute(const KKB::KKStr &_name, KKMLL::AttributeType _type, bool &alreadyExists)
FeatureVector(kkint32 _numOfFeatures)
unsigned __int16 kkuint16
16 bit unsigned integer.
const FileDescPtr FileDesc() const
FeatureNumList const FeatureNumListConst
KKStr operator+(const char *right) const
unsigned __int32 kkuint32
FeatureVectorList(FileDescPtr _fileDesc, bool _owner)
Will create a new empty list of FeatureVector's.
Container class for FeatureVector derived objects.
kkuint16 operator[](kkint32 idx) const
Returns back the selected feature.
KKStr operator+(const char *left, const KKStr &right)
Base class for all FeatureFileIO classes.
static KKStr Concat(const std::vector< std::string > &values)
Concatenates the list of 'std::string' strings.
virtual FeatureVectorListPtr LoadFile(const KKStr &_fileName, const FileDescPtr _fileDesc, MLClassList &_classes, istream &_in, kkint32 _maxCount, VolConstBool &_cancelFlag, bool &_changesMade, KKStr &_errorMessage, RunLog &_log)
void MLClass(MLClassPtr _mlClass)
Assign a class to this example.
Supports a simple Feature File format where each column represents a example and each row a feature v...
KKStr StrFormatInt(kkint32 val, const char *mask)
KKStr operator+(const KKStr &right) const
kkint32 NumSelFeatures() const
virtual FileDescPtr GetFileDesc(const KKStr &_fileName, istream &_in, MLClassListPtr _classList, kkint32 &_estSize, KKStr &_errorMessage, RunLog &_log)
Used for logging messages.
void EncodeProblem(const struct svm_paramater ¶m, struct svm_problem &prob_in, struct svm_problem &prob_out)
MLClassList * MLClassListPtr
virtual MLClassPtr GetMLClassPtr(const KKStr &_name)
return pointer to instance with '_name'; if none exists, create one and add to list.
Maintains a list of MLClass instances.
Represents a Feature Vector of a single example, labeled or unlabeled.
FeatureFileIO(const KKStr &_driverName, bool _canRead, bool _canWrite)
KKStr osGetRootName(const KKStr &fullFileName)
volatile const bool VolConstBool