GClasses
GClasses::GRelation Class Referenceabstract

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.

#include <GMatrix.h>

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

Public Types

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...
 
virtual void deleteAttributes (size_t index, size_t count)=0
 Deletes the specified attribute. 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
 Prints this relation in ARFF format to the specified stream. 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, char separator= ',', const char *missing="?") const
 Print a single row of data in ARFF format. More...
 
void save (const GMatrix *pData, const char *szFilename) 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...
 
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 (const 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...
 

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.

virtual void GClasses::GRelation::deleteAttributes ( size_t  index,
size_t  count 
)
pure virtual

Deletes the specified attribute.

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

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

Load from a DOM.

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

Prints this relation in ARFF format to the specified stream.

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,
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 
) 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.

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.