![]() |
KSquare Utilities
|
Provides a detailed description of the attributes of a dataset. More...
#include <FileDesc.h>
Public Types | |
| typedef FileDesc *const | FileDescConstPtr |
| typedef FileDesc * | FileDescPtr |
Public Member Functions | |
| FileDesc () | |
| void | AddAAttribute (const KKB::KKStr &_name, KKMLL::AttributeType _type, bool &alreadyExists) |
| void | AddAAttribute (const KKMLL::Attribute &attribute) |
| void | AddANominalValue (kkint32 fieldNum, const KKStr &nominalValue, bool &alreadyExist, RunLog &log) |
| void | AddANominalValue (const KKStr &nominalValue, bool &alreadyExist, RunLog &log) |
| void | AddANominalValue (const KKStr &attributeName, const KKStr &nominalValue, bool &alreadyExist, RunLog &log) |
| void | AddAttributes (const KKMLL::AttributeList &attributes) |
| void | AddClasses (const MLClassList &classesToAdd) |
| bool | AllFieldsAreNumeric () const |
| Allows the user to quickly determine if there are no nominal fields. More... | |
| const KKMLL::AttributeList & | Attributes () const |
| const AttributeTypeVector & | AttributeVector () const |
| kkint32 | Cardinality (kkint32 fieldNum) const |
| const VectorInt32 & | CardinalityVector () const |
| const MLClassList & | Classes () const |
| const KKStr & | ClassNameAttribute () const |
| void | ClassNameAttribute (const KKStr &_classNameAttribute) |
| const KKMLL::AttributePtr * | CreateAAttributeTable () const |
| AttributeTypeVector | CreateAttributeTypeTable () const |
| VectorInt32 | CreateCardinalityTable () const |
| void | DisplayAttributeMappings () |
| const KKStr & | FieldName (kkint32 fieldNum) const |
| const KKStr & | FileName () const |
| void | FileName (const KKStr &_fileName) |
| const KKMLL::Attribute & | GetAAttribute (kkint32 fieldNum) const |
| kkint32 | GetFieldNumFromAttributeName (const KKStr &attributeName) const |
| MLClassPtr | GetMLClassPtr (const KKStr &className) |
| const KKStr & | GetNominalValue (kkint32 fieldNum, kkint32 code) const |
| const KKMLL::AttributePtr | LookUpByName (const KKStr &attributeName) const |
| MLClassPtr | LookUpMLClassByName (const KKStr &className) |
| kkint32 | LookUpNominalCode (kkint32 fieldNum, const KKStr &nominalValue) const |
| MLClassPtr | LookUpUnKnownMLClass () |
| kkint32 | MemoryConsumedEstimated () const |
| kkuint32 | NumOfFields () const |
| bool | operator!= (const FileDesc &rightSize) const |
| Returns true if file description on the right size is NOT identical. More... | |
| bool | operator== (const FileDesc &rightSize) const |
| Returns true if file description on the right size is identical. More... | |
| void | ReadXML (XmlStream &s, XmlTagConstPtr tag, VolConstBool &cancelFlag, RunLog &log) |
| bool | SameExceptForSymbolicData (const FileDesc &otherFd, RunLog &log) const |
| kkint32 | SparseMinFeatureNum () const |
| void | SparseMinFeatureNum (kkint32 _sparseMinFeatureNum) |
| KKMLL::AttributeType | Type (kkint32 fieldNum) const |
| KKStr | TypeStr (kkint32 fieldNum) const |
| kkint16 | Version () const |
| void | Version (kkint16 _version) |
| void | WriteXML (const KKStr &varName, std::ostream &o) const |
Static Public Member Functions | |
| static void | FinalCleanUp () |
| Clean up function, call just before exiting the application. More... | |
| static bool | FinalCleanUpRanAlready () |
| static FileDescPtr | GetExistingFileDesc (FileDescPtr fileDesc) |
| Returns a pointer to an existing instance of 'fileDesc' if it exists, otherwise will use one being passed in. More... | |
| static FileDescPtr | MergeSymbolicFields (const FileDesc &left, const FileDesc &right, RunLog &log) |
| Merges the Symbolic fields of two different 'FileDesc' instances producing a new instance of 'FileDesc'. More... | |
| static FileDescPtr | NewContinuousDataOnly (VectorKKStr &_fieldNames) |
| Creates a simple FileDesc that consists of continuous data only. More... | |
Protected Member Functions | |
| ~FileDesc () | |
Friends | |
| class | KKQueue< FileDesc > |
Provides a detailed description of the attributes of a dataset.
Describes the different fields of a dataset. There will be one instance of this class for each type of Dataset that you have in an application. From this object you can get information such as number of attributes, Attribute types, weather they are nominal, continuous. If nominal what are the accepted values. *
Never delete an instance of a FileDesc object.
Only one FileDesc object can exist for any Dataset. Example the Forest-Cover dataset. You can split the data into many files and manage them separately but you will only have one instance of a FileDesc object that they will all refer to. See "GetExistingFileDesc" method below. You would initially create an instance of FileDesc and then use "GetExistingFileDesc" to make sure that it is unique. This typically happens in the FeatureFileIO derived classes.
Definition at line 72 of file FileDesc.h.
| typedef FileDesc* const KKMLL::FileDesc::FileDescConstPtr |
Definition at line 77 of file FileDesc.h.
| typedef FileDesc* KKMLL::FileDesc::FileDescPtr |
Definition at line 75 of file FileDesc.h.
| FileDesc::FileDesc | ( | ) |
Definition at line 81 of file FileDesc.cpp.
References FileDesc().
Referenced by KKMLL::FeatureEncoder2::CreateEncodedFileDesc(), KKMLL::FeatureEncoder::CreateEncodedFileDesc(), KKMLL::GrayScaleImagesFVProducer::DefineFileDescStatic(), FileDesc(), KKMLL::FeatureFileIODstWeb::GetFileDesc(), KKMLL::FeatureFileIOColumn::GetFileDesc(), KKMLL::FeatureFileIOC45::GetFileDesc(), KKMLL::FeatureFileIOUCI::GetFileDesc(), KKMLL::FeatureFileIOSparse::GetFileDesc(), MergeSymbolicFields(), NewContinuousDataOnly(), and KKMLL::XmlElementFileDesc::XmlElementFileDesc().
|
protected |
Definition at line 96 of file FileDesc.cpp.
| void FileDesc::AddAAttribute | ( | const KKB::KKStr & | _name, |
| KKMLL::AttributeType | _type, | ||
| bool & | alreadyExists | ||
| ) |
Definition at line 169 of file FileDesc.cpp.
References KKMLL::Numeric, and KKMLL::Attribute::Type().
Referenced by KKMLL::FeatureEncoder2::CreateEncodedFileDesc(), KKMLL::FeatureEncoder::CreateEncodedFileDesc(), KKMLL::GrayScaleImagesFVProducer::DefineFileDescStatic(), KKMLL::FeatureFileIOColumn::GetFileDesc(), KKMLL::FeatureFileIOUCI::GetFileDesc(), KKMLL::FeatureFileIOSparse::GetFileDesc(), and NewContinuousDataOnly().
| void FileDesc::AddAAttribute | ( | const KKMLL::Attribute & | attribute | ) |
Definition at line 140 of file FileDesc.cpp.
References KKMLL::Numeric, and KKMLL::Attribute::Type().
Referenced by MergeSymbolicFields().
| void FileDesc::AddANominalValue | ( | kkint32 | fieldNum, |
| const KKStr & | nominalValue, | ||
| bool & | alreadyExist, | ||
| RunLog & | log | ||
| ) |
Definition at line 220 of file FileDesc.cpp.
References KKMLL::Nominal, KKMLL::Symbolic, and Type().
Referenced by MergeSymbolicFields().
Definition at line 242 of file FileDesc.cpp.
References KKMLL::Attribute::AddANominalValue(), KKB::KKStr::Concat(), and KKB::KKException::KKException().
Referenced by AddANominalValue(), and KKMLL::FeatureFileIODstWeb::GetFileDesc().
| void FileDesc::AddANominalValue | ( | const KKStr & | attributeName, |
| const KKStr & | nominalValue, | ||
| bool & | alreadyExist, | ||
| RunLog & | log | ||
| ) |
Definition at line 264 of file FileDesc.cpp.
References AddANominalValue(), KKB::KKStr::Concat(), KKB::KKException::KKException(), and KKB::KKStr::KKStr().
| void FileDesc::AddAttributes | ( | const KKMLL::AttributeList & | attributes | ) |
Definition at line 156 of file FileDesc.cpp.
| void FileDesc::AddClasses | ( | const MLClassList & | classesToAdd | ) |
Definition at line 196 of file FileDesc.cpp.
Referenced by KKMLL::FeatureFileIOC45::GetFileDesc(), and ReadXML().
| bool FileDesc::AllFieldsAreNumeric | ( | ) | const |
Allows the user to quickly determine if there are no nominal fields.
Example use is in CrossValidation application, by using this method it can quickly determine if it is worth while using encoding.
Definition at line 706 of file FileDesc.cpp.
References KKMLL::Ignore, KKMLL::Numeric, NumOfFields(), and Type().
Referenced by KKMLL::FeatureVectorList::AllFieldsAreNumeric().
|
inline |
Definition at line 114 of file FileDesc.h.
|
inline |
Definition at line 115 of file FileDesc.h.
Referenced by KKMLL::FeatureNumList::AllFeatures(), and KKMLL::FeatureEncoder2::FeatureEncoder2().
Definition at line 341 of file FileDesc.cpp.
References KKMLL::Attribute::Cardinality(), KKB::KKStr::Concat(), KKMLL::Ignore, KKB::KKException::KKException(), KKMLL::Nominal, KKMLL::Numeric, KKB::operator<<(), KKMLL::Symbolic, and KKMLL::Attribute::Type().
Referenced by KKMLL::FeatureVectorList::FeatureCardinality(), MergeSymbolicFields(), KKMLL::ModelParam::NumOfFeaturesAfterEncoding(), KKMLL::SVMparam::NumOfFeaturesAfterEncoding(), and KKMLL::FeatureVectorList::ReSyncSymbolicData().
|
inline |
Definition at line 116 of file FileDesc.h.
Referenced by KKMLL::FeatureEncoder2::FeatureEncoder2().
|
inline |
Definition at line 117 of file FileDesc.h.
|
inline |
ClassNameAttribute added to support dstWeb data files.
Definition at line 118 of file FileDesc.h.
Referenced by KKMLL::FeatureFileIODstWeb::LoadFile().
|
inline |
Definition at line 123 of file FileDesc.h.
References KKB::KKStr::operator=().
| const AttributePtr * FileDesc::CreateAAttributeTable | ( | ) | const |
Caller will be responsible for deleting
Definition at line 408 of file FileDesc.cpp.
Referenced by KKMLL::FeatureFileIODstWeb::LoadFile(), KKMLL::FeatureFileIOC45::LoadFile(), KKMLL::FeatureFileIORoberts::SaveFile(), and KKMLL::FeatureFileIOC45::SaveFile().
| AttributeTypeVector FileDesc::CreateAttributeTypeTable | ( | ) | const |
Definition at line 419 of file FileDesc.cpp.
Referenced by KKMLL::FeatureVectorList::CreateAttributeTypeTable(), KKMLL::NormalizationParms::NormalizationParms(), KKMLL::NormalizationParms::ReadXML(), KKMLL::SVMModel::ReadXML(), and KKMLL::SVMModel::SVMModel().
| VectorInt32 FileDesc::CreateCardinalityTable | ( | ) | const |
Definition at line 430 of file FileDesc.cpp.
Referenced by KKMLL::FeatureVectorList::CreateCardinalityTable(), KKMLL::SVMModel::ReadXML(), and KKMLL::SVMModel::SVMModel().
| void FileDesc::DisplayAttributeMappings | ( | ) |
Definition at line 617 of file FileDesc.cpp.
References KKMLL::Attribute::Cardinality(), KKMLL::Attribute::GetNominalCode(), KKMLL::Attribute::GetNominalValue(), KKMLL::Ignore, KKMLL::Nominal, KKMLL::NULLAttribute, KKMLL::Numeric, NumOfFields(), KKMLL::Ordinal, KKMLL::Symbolic, and KKMLL::Attribute::Type().
Definition at line 387 of file FileDesc.cpp.
Referenced by KKMLL::FeatureEncoder2::CreateEncodedFileDesc(), KKMLL::FeatureEncoder::CreateEncodedFileDesc(), KKMLL::FeatureVectorProducer::FeatureName(), KKMLL::FeatureVectorList::FieldName(), MergeSymbolicFields(), KKMLL::FeatureVectorList::ReSyncSymbolicData(), and SameExceptForSymbolicData().
|
inline |
Definition at line 119 of file FileDesc.h.
Referenced by SameExceptForSymbolicData().
|
inline |
Definition at line 124 of file FileDesc.h.
References KKB::KKStr::operator=().
|
static |
Clean up function, call just before exiting the application.
Before you terminate your application you should call this method. It will clean up the FileDesc objects that were created during the runtime of your application.
Definition at line 57 of file FileDesc.cpp.
References KKB::GoalKeeper::Destroy(), KKB::GoalKeeper::EndBlock(), and KKB::GoalKeeper::StartBlock().
Referenced by KKMLL::MLClass::FinalCleanUp().
|
inlinestatic |
Definition at line 88 of file FileDesc.h.
Referenced by KKMLL::MLClass::FinalCleanUp().
Definition at line 210 of file FileDesc.cpp.
Referenced by KKMLL::FeatureEncoder::FeatureEncoder(), and MergeSymbolicFields().
|
static |
Returns a pointer to an existing instance of 'fileDesc' if it exists, otherwise will use one being passed in.
First looks to see if a the same FileDesc is already in the existing list
in that case will return back the same pointer.
| [in] | fileDesc | Pointer to a FileDesc object that you want to look and see if one that is identical already exists. |
Definition at line 555 of file FileDesc.cpp.
References KKB::KKStr::Concat(), KKB::GoalKeeper::EndBlock(), KKMLL::FileDescList::FileDescList(), KKB::KKException::KKException(), and KKB::GoalKeeper::StartBlock().
Referenced by KKMLL::FeatureEncoder2::CreateEncodedFileDesc(), KKMLL::GrayScaleImagesFVProducer::DefineFileDescStatic(), KKMLL::FeatureVectorProducer::FileDesc(), KKMLL::FeatureFileIOC45::LoadFeatureFile(), KKMLL::FeatureFileIO::LoadFeatureFile(), MergeSymbolicFields(), NewContinuousDataOnly(), and KKMLL::XmlElementFileDesc::XmlElementFileDesc().
Definition at line 690 of file FileDesc.cpp.
References KKMLL::Attribute::FieldNum().
Referenced by KKMLL::FeatureFileIODstWeb::LoadFile().
| MLClassPtr FileDesc::GetMLClassPtr | ( | const KKStr & | className | ) |
Definition at line 298 of file FileDesc.cpp.
Definition at line 395 of file FileDesc.cpp.
Referenced by KKMLL::FeatureEncoder2::CreateEncodedFileDesc(), KKMLL::FeatureEncoder::CreateEncodedFileDesc(), MergeSymbolicFields(), and KKMLL::FeatureVectorList::ReSyncSymbolicData().
| const AttributePtr FileDesc::LookUpByName | ( | const KKStr & | attributeName | ) | const |
Definition at line 682 of file FileDesc.cpp.
| MLClassPtr FileDesc::LookUpMLClassByName | ( | const KKStr & | className | ) |
Definition at line 284 of file FileDesc.cpp.
Referenced by KKMLL::FeatureFileIOC45::LoadFile().
Definition at line 321 of file FileDesc.cpp.
References KKMLL::Attribute::GetNominalCode(), KKMLL::Nominal, KKMLL::Symbolic, and KKMLL::Attribute::Type().
Referenced by MergeSymbolicFields(), and KKMLL::FeatureVectorList::ReSyncSymbolicData().
| MLClassPtr FileDesc::LookUpUnKnownMLClass | ( | ) |
Definition at line 291 of file FileDesc.cpp.
Referenced by KKMLL::FeatureFileIOC45::LoadFile().
| kkint32 FileDesc::MemoryConsumedEstimated | ( | ) | const |
Definition at line 102 of file FileDesc.cpp.
|
static |
Merges the Symbolic fields of two different 'FileDesc' instances producing a new instance of 'FileDesc'.
This method will only work if both instances have the same number of fields, their names must be the same(NOT case sensitive), and each field in both instances must be the same type. If all these conditions are not 'true' will return NULL. The fields that are of 'Symbolic' will have their values merged together.
Definition at line 723 of file FileDesc.cpp.
References AddAAttribute(), AddANominalValue(), Cardinality(), KKB::KKStr::Concat(), FieldName(), FileDesc(), GetAAttribute(), GetExistingFileDesc(), GetNominalValue(), LookUpNominalCode(), NumOfFields(), KKB::KKStr::operator!=(), SameExceptForSymbolicData(), KKMLL::Symbolic, and Type().
Referenced by KKMLL::FeatureVectorList::SynchronizeSymbolicData().
|
static |
Creates a simple FileDesc that consists of continuous data only.
Creates a file description that will consist of continuous fields only. The vector '_fieldNames' will provide the list of field names.
| [in] | _log | Logging file to use. |
| [in] | _fieldNames | Name of fields; one entry for each field. |
Definition at line 116 of file FileDesc.cpp.
References AddAAttribute(), KKB::KKStr::Concat(), FileDesc(), GetExistingFileDesc(), KKMLL::Numeric, and KKB::StrFormatInt().
Referenced by KKMLL::FeatureEncoder::FeatureEncoder(), and KKMLL::FeatureEncoder2::FeatureEncoder2().
|
inline |
Definition at line 197 of file FileDesc.h.
Referenced by KKMLL::FeatureNumList::AllFeatures(), KKMLL::FeatureNumList::AllFeaturesSelected(), AllFieldsAreNumeric(), DisplayAttributeMappings(), KKMLL::FeatureVectorProducer::FeatureCount(), KKMLL::FeatureVectorProducer::FeatureName(), KKMLL::FeatureNumList::FeatureNumList(), KKMLL::FeatureVectorList::FeatureVectorList(), KKMLL::FeatureFileIODstWeb::LoadFile(), KKMLL::FeatureFileIOColumn::LoadFile(), KKMLL::FeatureFileIOUCI::LoadFile(), KKMLL::FeatureFileIOC45::LoadFile(), KKMLL::FeatureFileIOSparse::LoadFile(), MergeSymbolicFields(), KKMLL::FeatureEncoder2::NumEncodedFeatures(), KKMLL::FeatureVectorList::ResetFileDesc(), KKMLL::FeatureVectorList::ReSyncSymbolicData(), SameExceptForSymbolicData(), and KKMLL::FeatureNumList::ToHexString().
| bool FileDesc::operator!= | ( | const FileDesc & | rightSize | ) | const |
Returns true if file description on the right size is NOT identical.
If both FileDesc instances have different number of fields, or any one of the fields has a different name(NOT case sensitive), or one of the fields is of a different type.
Definition at line 456 of file FileDesc.cpp.
| bool FileDesc::operator== | ( | const FileDesc & | rightSize | ) | const |
Returns true if file description on the right size is identical.
Both FileDesc instances must have the same number of fields, the fields must have the same names(NOT case sensitive), and the fields must have matching types(ex numerical, ordinal, etc).
Definition at line 443 of file FileDesc.cpp.
Referenced by KKMLL::FeatureFileIO::FeatureDataReSink().
| void FileDesc::ReadXML | ( | XmlStream & | s, |
| XmlTagConstPtr | tag, | ||
| VolConstBool & | cancelFlag, | ||
| RunLog & | log | ||
| ) |
Definition at line 800 of file FileDesc.cpp.
References AddClasses(), KKB::KKStr::Concat(), KKB::KKStr::EqualIgnoreCase(), KKB::XmlStream::GetNextToken(), KKB::XmlElement::SectionName(), SparseMinFeatureNum(), KKB::XmlToken::tokElement, KKB::XmlToken::TokenType(), KKMLL::XmlElementMLClassNameList::Value(), KKB::XmlElement::VarName(), and Version().
Referenced by KKMLL::XmlElementFileDesc::XmlElementFileDesc().
Definition at line 472 of file FileDesc.cpp.
References KKB::KKStr::Concat(), FieldName(), FileName(), NumOfFields(), KKB::KKStr::operator!=(), and Type().
Referenced by MergeSymbolicFields(), KKMLL::FeatureVectorList::SameExceptForSymbolicData(), and KKMLL::FeatureVectorList::SynchronizeSymbolicData().
|
inline |
Definition at line 120 of file FileDesc.h.
Referenced by KKMLL::FeatureFileIOSparse::LoadFile(), and KKMLL::FeatureFileIOSparse::SaveFile().
|
inline |
Definition at line 125 of file FileDesc.h.
Referenced by KKMLL::FeatureFileIOSparse::GetFileDesc(), and ReadXML().
| AttributeType FileDesc::Type | ( | kkint32 | fieldNum | ) | const |
Definition at line 370 of file FileDesc.cpp.
Referenced by AddANominalValue(), AllFieldsAreNumeric(), KKMLL::FeatureVectorList::FeatureType(), KKMLL::FeatureVectorList::FeatureTypeStr(), MergeSymbolicFields(), KKMLL::ModelParam::NumOfFeaturesAfterEncoding(), KKMLL::SVMparam::NumOfFeaturesAfterEncoding(), KKMLL::FeatureVectorList::ReSyncSymbolicData(), SameExceptForSymbolicData(), and KKMLL::FeatureNumList::SetAllFeatures().
Definition at line 378 of file FileDesc.cpp.
Referenced by KKMLL::FeatureEncoder2::CreateEncodedFileDesc(), and KKMLL::FeatureEncoder::CreateEncodedFileDesc().
|
inline |
Definition at line 121 of file FileDesc.h.
|
inline |
Definition at line 126 of file FileDesc.h.
Referenced by KKMLL::GrayScaleImagesFVProducer::DefineFileDescStatic(), and ReadXML().
| void FileDesc::WriteXML | ( | const KKStr & | varName, |
| std::ostream & | o | ||
| ) | const |
Definition at line 875 of file FileDesc.cpp.
References KKB::XmlTag::AddAtribute(), KKB::KKStr::Empty(), KKB::XmlTag::tagEnd, KKB::XmlTag::tagStart, KKB::XmlTag::WriteXML(), and KKB::XmlTag::XmlTag().
Referenced by KKMLL::Model::WriteModelXMLFields(), KKMLL::FeatureEncoder::WriteXML(), SVM289_MFS::Svm_Model::WriteXML(), KKMLL::SVMModel::WriteXML(), and KKMLL::XmlElementFileDesc::WriteXML().
Definition at line 107 of file FileDesc.h.