GClasses
GClasses::GRelation Class Referenceabstract

Holds the metadata for a dataset. More...

#include <GMatrix.h>

Inheritance diagram for GClasses::GRelation:
GClasses::GMixedRelation GClasses::GUniformRelation GClasses::GArffRelation

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 GRelationclone () const =0
 Makes a deep copy of this relation. More...
 
virtual GRelationcloneMinimal () 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 GRelationcloneSub (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 GDomNodeserialize (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 GRelationdeserialize (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...
 

Detailed Description

Holds the metadata for a dataset.

The metadata includes which attributes are continuous or nominal, and how many values each nominal attribute supports.

Member Enumeration Documentation

Enumerator
UNIFORM 
MIXED 
ARFF 

Constructor & Destructor Documentation

GClasses::GRelation::GRelation ( )
inline
virtual GClasses::GRelation::~GRelation ( )
inlinevirtual

Member Function Documentation

virtual bool GClasses::GRelation::areContinuous ( size_t  first = 0,
size_t  count = INVALID_INDEX 
) const
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.

virtual bool GClasses::GRelation::areNominal ( size_t  first = 0,
size_t  count = INVALID_INDEX 
) const
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.

virtual std::string GClasses::GRelation::attrNameStr ( std::size_t  nAttr) const
inlinevirtual

Returns the name of the attribute with index nAttr as a standard string object or "" if the atribute has no name.

Parameters
nAttrthe index of the attribute whose name is returned
Returns
the name of the attribute with index nAttr as a standard string object or "" if the atribute has no name

Reimplemented in GClasses::GArffRelation.

virtual GRelation* GClasses::GRelation::clone ( ) const
pure virtual

Makes a deep copy of this relation.

Implemented in GClasses::GArffRelation, GClasses::GMixedRelation, and GClasses::GUniformRelation.

virtual GRelation* GClasses::GRelation::cloneMinimal ( ) const
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.

virtual GRelation* GClasses::GRelation::cloneSub ( size_t  start,
size_t  count 
) const
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.

virtual void GClasses::GRelation::deleteAttribute ( size_t  index)
pure virtual

Deletes the specified attribute.

Implemented in GClasses::GArffRelation, GClasses::GMixedRelation, and GClasses::GUniformRelation.

static GRelation* GClasses::GRelation::deserialize ( GDomNode pNode)
static

Load from a DOM.

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 bool GClasses::GRelation::isCompatible ( const GRelation that) const
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 void GClasses::GRelation::printAttrName ( std::ostream &  stream,
size_t  column 
) const
virtual

Prints the specified attribute name to a stream.

Reimplemented in GClasses::GArffRelation.

virtual void GClasses::GRelation::printAttrValue ( std::ostream &  stream,
size_t  column,
double  value,
const char *  missing = "?" 
) const
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.

virtual GDomNode* GClasses::GRelation::serialize ( GDom pDoc) const
pure virtual

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.

virtual size_t GClasses::GRelation::size ( ) const
pure virtual

Returns the number of attributes (columns)

Implemented in GClasses::GMixedRelation, and GClasses::GUniformRelation.

virtual void GClasses::GRelation::swapAttributes ( size_t  nAttr1,
size_t  nAttr2 
)
pure virtual
static void GClasses::GRelation::test ( )
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)

virtual RelationType GClasses::GRelation::type ( ) const
pure virtual

Returns the type of relation.

Implemented in GClasses::GArffRelation, GClasses::GMixedRelation, and GClasses::GUniformRelation.

virtual size_t GClasses::GRelation::valueCount ( size_t  nAttr) const
pure virtual

Returns the number of values in the specified attribute. (Returns 0 for continuous attributes.)

Implemented in GClasses::GMixedRelation, and GClasses::GUniformRelation.