GClasses
|
Holds the metadata for a dataset. More...
#include <GMatrix.h>
Public Types | |
enum | RelationType { UNIFORM, MIXED, ARFF } |
Public Member Functions | |
GRelation () | |
virtual | ~GRelation () |
virtual bool | areContinuous (size_t first=0, size_t count=INVALID_INDEX) const =0 |
Returns true iff all of the attributes in the specified range are continuous. The default range is all of them. More... | |
virtual bool | areNominal (size_t first=0, size_t count=INVALID_INDEX) const =0 |
Returns true iff all of the attributes in the specified range are nominal. The default range is all of them. More... | |
virtual std::string | attrNameStr (std::size_t nAttr) const |
Returns the name of the attribute with index nAttr as a standard string object or "" if the atribute has no name. More... | |
virtual GRelation * | clone () const =0 |
Makes a deep copy of this relation. More... | |
virtual GRelation * | cloneMinimal () const =0 |
Returns a relation containing the same value counts as this object, but not containing superfluous things, such as human-readable strings. (The returned relation may be of a different type.) More... | |
virtual GRelation * | cloneSub (size_t start, size_t count) const =0 |
Makes a deep copy of the specified subset of this relation. More... | |
size_t | countRealSpaceDims (size_t nFirstAttr, size_t nAttrCount) const |
Counts the size of the corresponding real-space vector. More... | |
virtual void | deleteAttribute (size_t index)=0 |
Deletes the specified attribute. More... | |
void | fromRealSpace (const double *pIn, double *pOut, size_t nFirstAttr, size_t nAttrCount, GRand *pRand) const |
Converts a real-space vector (pIn) to a row (pOut) More... | |
void | fromRealSpace (const double *pIn, GPrediction *pOut, size_t nFirstAttr, size_t nAttrCount) const |
Converts a real-space vector (pIn) to an array of predictions (pOut) More... | |
virtual bool | isCompatible (const GRelation &that) const |
Returns true iff this and that have the same number of values for each attribute. More... | |
void | print (std::ostream &stream, const GMatrix *pData, size_t precision) const |
Prints as an ARFF file to the specified stream. (pData can be NULL if data is not available) More... | |
virtual void | printAttrName (std::ostream &stream, size_t column) const |
Prints the specified attribute name to a stream. More... | |
virtual void | printAttrValue (std::ostream &stream, size_t column, double value, const char *missing="?") const |
Prints the specified value to a stream. More... | |
void | printRow (std::ostream &stream, const double *pRow, const char *separator, const char *missing="?") const |
Print a single row of data in ARFF format. More... | |
void | save (const GMatrix *pData, const char *szFilename, size_t precision) const |
Saves to a file. More... | |
virtual GDomNode * | serialize (GDom *pDoc) const =0 |
Marshal this object into a DOM, which can then be converted to a variety of serial formats. More... | |
virtual size_t | size () const =0 |
Returns the number of attributes (columns) More... | |
virtual void | swapAttributes (size_t nAttr1, size_t nAttr2)=0 |
Swaps two attributes. More... | |
void | toRealSpace (const double *pIn, double *pOut, size_t nFirstAttr, size_t nAttrCount) const |
Converts a row (pIn) to a real-space vector (pOut) (pIn should point to the nFirstAttr'th element, not the first element) More... | |
virtual RelationType | type () const =0 |
Returns the type of relation. More... | |
virtual size_t | valueCount (size_t nAttr) const =0 |
Returns the number of values in the specified attribute. (Returns 0 for continuous attributes.) More... | |
Static Public Member Functions | |
static GRelation * | deserialize (GDomNode *pNode) |
Load from a DOM. More... | |
static void | test () |
Performs unit tests for this class. Throws an exception if there is a failure. More... | |
Holds the metadata for a dataset.
The metadata includes which attributes are continuous or nominal, and how many values each nominal attribute supports.
|
inline |
|
inlinevirtual |
|
pure virtual |
Returns true iff all of the attributes in the specified range are continuous. The default range is all of them.
Implemented in GClasses::GMixedRelation, and GClasses::GUniformRelation.
|
pure virtual |
Returns true iff all of the attributes in the specified range are nominal. The default range is all of them.
Implemented in GClasses::GMixedRelation, and GClasses::GUniformRelation.
|
inlinevirtual |
Returns the name of the attribute with index nAttr as a standard string object or "" if the atribute has no name.
nAttr | the index of the attribute whose name is returned |
Reimplemented in GClasses::GArffRelation.
|
pure virtual |
Makes a deep copy of this relation.
Implemented in GClasses::GArffRelation, GClasses::GMixedRelation, and GClasses::GUniformRelation.
|
pure virtual |
Returns a relation containing the same value counts as this object, but not containing superfluous things, such as human-readable strings. (The returned relation may be of a different type.)
Implemented in GClasses::GArffRelation, GClasses::GMixedRelation, and GClasses::GUniformRelation.
|
pure virtual |
Makes a deep copy of the specified subset of this relation.
Implemented in GClasses::GArffRelation, GClasses::GMixedRelation, and GClasses::GUniformRelation.
size_t GClasses::GRelation::countRealSpaceDims | ( | size_t | nFirstAttr, |
size_t | nAttrCount | ||
) | const |
Counts the size of the corresponding real-space vector.
|
pure virtual |
Deletes the specified attribute.
Implemented in GClasses::GArffRelation, GClasses::GMixedRelation, and GClasses::GUniformRelation.
void GClasses::GRelation::fromRealSpace | ( | const double * | pIn, |
double * | pOut, | ||
size_t | nFirstAttr, | ||
size_t | nAttrCount, | ||
GRand * | pRand | ||
) | const |
Converts a real-space vector (pIn) to a row (pOut)
nFirstAttr and nAttrCount refer to the row indexes
void GClasses::GRelation::fromRealSpace | ( | const double * | pIn, |
GPrediction * | pOut, | ||
size_t | nFirstAttr, | ||
size_t | nAttrCount | ||
) | const |
Converts a real-space vector (pIn) to an array of predictions (pOut)
nFirstAttr and nAttrCount refer to the prediction indexes
|
virtual |
Returns true iff this and that have the same number of values for each attribute.
Reimplemented in GClasses::GArffRelation, and GClasses::GUniformRelation.
void GClasses::GRelation::print | ( | std::ostream & | stream, |
const GMatrix * | pData, | ||
size_t | precision | ||
) | const |
Prints as an ARFF file to the specified stream. (pData can be NULL if data is not available)
|
virtual |
Prints the specified attribute name to a stream.
Reimplemented in GClasses::GArffRelation.
|
virtual |
Prints the specified value to a stream.
Reimplemented in GClasses::GArffRelation.
void GClasses::GRelation::printRow | ( | std::ostream & | stream, |
const double * | pRow, | ||
const char * | separator, | ||
const char * | missing = "?" |
||
) | const |
Print a single row of data in ARFF format.
void GClasses::GRelation::save | ( | const GMatrix * | pData, |
const char * | szFilename, | ||
size_t | precision | ||
) | const |
Saves to a file.
Marshal this object into a DOM, which can then be converted to a variety of serial formats.
Implemented in GClasses::GArffRelation, GClasses::GMixedRelation, and GClasses::GUniformRelation.
|
pure virtual |
Returns the number of attributes (columns)
Implemented in GClasses::GMixedRelation, and GClasses::GUniformRelation.
|
pure virtual |
Swaps two attributes.
Implemented in GClasses::GArffRelation, GClasses::GMixedRelation, and GClasses::GUniformRelation.
|
static |
Performs unit tests for this class. Throws an exception if there is a failure.
void GClasses::GRelation::toRealSpace | ( | const double * | pIn, |
double * | pOut, | ||
size_t | nFirstAttr, | ||
size_t | nAttrCount | ||
) | const |
Converts a row (pIn) to a real-space vector (pOut) (pIn should point to the nFirstAttr'th element, not the first element)
|
pure virtual |
Returns the type of relation.
Implemented in GClasses::GArffRelation, GClasses::GMixedRelation, and GClasses::GUniformRelation.
|
pure virtual |
Returns the number of values in the specified attribute. (Returns 0 for continuous attributes.)
Implemented in GClasses::GMixedRelation, and GClasses::GUniformRelation.