GClasses
GClasses::GUniformRelation Class Reference

A relation with a minimal memory footprint that assumes all attributes are continuous, or all of them are nominal and have the same number of possible values. More...

#include <GMatrix.h>

Inheritance diagram for GClasses::GUniformRelation:
GClasses::GRelation

Public Member Functions

 GUniformRelation (size_t attrCount, size_t valueCount=0)
 
 GUniformRelation (GDomNode *pNode)
 
virtual bool areContinuous (size_t first=0, size_t count=INVALID_INDEX) const
 See the comment for GRelation::areContinuous. More...
 
virtual bool areNominal (size_t first=0, size_t count=INVALID_INDEX) const
 See the comment for GRelation::areNominal. More...
 
virtual GRelationclone () const
 Returns a copy of this object. More...
 
virtual GRelationcloneMinimal () const
 Returns a copy of this object. More...
 
virtual GRelationcloneSub (size_t, size_t count) const
 Returns a deep copy of the specified subset of this relation. More...
 
virtual void deleteAttribute (size_t index)
 Drop 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...
 
virtual GDomNodeserialize (GDom *pDoc) const
 Serializes this object. More...
 
virtual size_t size () const
 Returns the number of attributes (columns) More...
 
virtual void swapAttributes (size_t, size_t)
 Swap two attributes (since all attributes are identical, does nothing) More...
 
virtual RelationType type () const
 Returns the type of relation. More...
 
virtual size_t valueCount (size_t) const
 Returns the number of values in each nominal attribute (or 0 if the attributes are continuous) More...
 
- Public Member Functions inherited from GClasses::GRelation
 GRelation ()
 
virtual ~GRelation ()
 
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...
 
size_t countRealSpaceDims (size_t nFirstAttr, size_t nAttrCount) const
 Counts the size of the corresponding real-space vector. 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...
 
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...
 
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...
 

Protected Attributes

size_t m_attrCount
 
size_t m_valueCount
 

Additional Inherited Members

- Public Types inherited from GClasses::GRelation
enum  RelationType { UNIFORM, MIXED, ARFF }
 
- Static Public Member Functions inherited from GClasses::GRelation
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

A relation with a minimal memory footprint that assumes all attributes are continuous, or all of them are nominal and have the same number of possible values.

Constructor & Destructor Documentation

GClasses::GUniformRelation::GUniformRelation ( size_t  attrCount,
size_t  valueCount = 0 
)
inline
GClasses::GUniformRelation::GUniformRelation ( GDomNode pNode)

Member Function Documentation

virtual bool GClasses::GUniformRelation::areContinuous ( size_t  first = 0,
size_t  count = INVALID_INDEX 
) const
inlinevirtual

See the comment for GRelation::areContinuous.

Implements GClasses::GRelation.

virtual bool GClasses::GUniformRelation::areNominal ( size_t  first = 0,
size_t  count = INVALID_INDEX 
) const
inlinevirtual

See the comment for GRelation::areNominal.

Implements GClasses::GRelation.

virtual GRelation* GClasses::GUniformRelation::clone ( ) const
inlinevirtual

Returns a copy of this object.

Implements GClasses::GRelation.

virtual GRelation* GClasses::GUniformRelation::cloneMinimal ( ) const
inlinevirtual

Returns a copy of this object.

Implements GClasses::GRelation.

virtual GRelation* GClasses::GUniformRelation::cloneSub ( size_t  ,
size_t  count 
) const
inlinevirtual

Returns a deep copy of the specified subset of this relation.

Implements GClasses::GRelation.

virtual void GClasses::GUniformRelation::deleteAttribute ( size_t  index)
virtual

Drop the specified attribute.

Implements GClasses::GRelation.

virtual bool GClasses::GUniformRelation::isCompatible ( const GRelation that) const
virtual

Returns true iff this and that have the same number of values for each attribute.

Reimplemented from GClasses::GRelation.

virtual GDomNode* GClasses::GUniformRelation::serialize ( GDom pDoc) const
virtual

Serializes this object.

Implements GClasses::GRelation.

virtual size_t GClasses::GUniformRelation::size ( ) const
inlinevirtual

Returns the number of attributes (columns)

Implements GClasses::GRelation.

virtual void GClasses::GUniformRelation::swapAttributes ( size_t  ,
size_t   
)
inlinevirtual

Swap two attributes (since all attributes are identical, does nothing)

Implements GClasses::GRelation.

virtual RelationType GClasses::GUniformRelation::type ( ) const
inlinevirtual

Returns the type of relation.

Implements GClasses::GRelation.

virtual size_t GClasses::GUniformRelation::valueCount ( size_t  ) const
inlinevirtual

Returns the number of values in each nominal attribute (or 0 if the attributes are continuous)

Implements GClasses::GRelation.

Member Data Documentation

size_t GClasses::GUniformRelation::m_attrCount
protected
size_t GClasses::GUniformRelation::m_valueCount
protected