28 using namespace KKMLL;
56 _log.Level (20) <<
"FeatureFileIOUCI::GetFileDesc FileName[" << _fileName <<
"]." << endl;
77 numFieldsThisLine = 0;
87 className
= "UnKnown";
92 numOfFields = Max (numOfFields, numFieldsThisLine);
98 bool alreadyExists =
false;
103 for (fieldNum = 0; fieldNum < numOfFields; fieldNum++)
123 KKStr& _errorMessage,
127 _log.Level (20) <<
"FeatureFileIOUCI::LoadFile FileName[" << _fileName <<
"]" << endl;
153 for (featureNum = 0; featureNum < numOfFeatures; featureNum++)
156 example->AddFeatureData (featureNum, (
float)atof (featureStr.Str ()));
182 const KKStr& _fileName,
188 KKStr& _errorMessage,
193 FeatureVectorPtr example = NULL;
195 _numExamplesWritten = 0;
202 _out <<
"ExampleFileName";
206 _out <<
"," << fileDesc->FieldName (featureNum);
208 _out <<
"," <<
"ClassLabel" << endl;
210 for (idx = 0; idx < _data.QueueSize (); idx++)
212 example = _data.IdxToPtr (idx);
214 _out << (
"Train_" + KKB::osGetRootName (example->ExampleFileName ())) <<
",";
219 _out << example->FeatureData (featureNum) <<
",";
223 _numExamplesWritten++;
KKStr(kkint32 size)
Creates a KKStr object that pre-allocates space for 'size' characters.
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...
Provides a detailed description of the attributes of a dataset.
kkuint32 NumOfFields() const
void AddAAttribute(const KKB::KKStr &_name, KKMLL::AttributeType _type, bool &alreadyExists)
KKStr & TrimRight(const char *whiteSpaceChars="\n\r\t ")
FeatureVector(kkint32 _numOfFeatures)
KKStr ExtractToken(const char *delStr="\n\t\r ")
virtual FileDescPtr GetFileDesc(const KKStr &_fileName, istream &_in, MLClassListPtr _classList, kkint32 &_estSize, KKStr &_errorMessage, RunLog &_log)
KKStr & operator=(const char *src)
const FileDescPtr FileDesc() const
FeatureNumList const FeatureNumListConst
Supports the reading and writing of Feature data from a file format commonly used by many dataset's i...
KKStr operator+(const char *right) const
void GetLine(std::istream &_in, KKStr &_line, bool &_eof)
unsigned __int32 kkuint32
FeatureVectorList(FileDescPtr _fileDesc, bool _owner)
Will create a new empty list of FeatureVector's.
KKStr & operator=(KKStr &&src)
bool operator!=(const char *rtStr) const
Container class for FeatureVector derived objects.
kkuint16 operator[](kkint32 idx) const
Returns back the selected feature.
KKStr operator+(const char *left, const KKStr &right)
kkint32 NumOfFeatures() const
void TrimLeft(const char *whiteSpaceChars="\n\r\t ")
Base class for all FeatureFileIO classes.
KKStr SubStrPart(kkint32 firstChar, kkint32 lastChar) const
returns a SubString consisting of all characters starting at index 'firstChar' and ending at 'lastInd...
static KKStr Concat(const std::vector< std::string > &values)
Concatenates the list of 'std::string' strings.
void MLClass(MLClassPtr _mlClass)
Assign a class to this example.
KKStr StrFormatInt(kkint32 val, const char *mask)
std::ostream &__cdecl operator<<(std::ostream &os, const KKStr &str)
KKStr operator+(const KKStr &right) const
virtual FeatureVectorListPtr LoadFile(const KKStr &_fileName, const FileDescPtr _fileDesc, MLClassList &_classes, istream &_in, kkint32 _maxCount, VolConstBool &_cancelFlag, bool &_changesMade, 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 void SaveFile(FeatureVectorList &_data, const KKStr &_fileName, FeatureNumListConst &_selFeatures, ostream &_out, kkuint32 &_numExamplesWritten, VolConstBool &_cancelFlag, bool &_successful, KKStr &_errorMessage, RunLog &_log)
virtual MLClassPtr GetMLClassPtr(const KKStr &_name)
return pointer to instance with '_name'; if none exists, create one and add to list.
const KKStr & ClassName() const
Name of class that this example is assigned to.
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