GClasses
GClasses::GMixedRelation Class Reference

#include <GMatrix.h>

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

Public Member Functions

 GMixedRelation ()
 Makes an empty relation. More...
 
 GMixedRelation (std::vector< size_t > &attrValues)
 Construct a mixed relation. attrValues specifies the number of nominal values in each attribute (column), or 0 for continuous attributes. More...
 
 GMixedRelation (const GDomNode *pNode)
 Loads from a DOM. More...
 
 GMixedRelation (const GRelation *pCopyMe)
 Makes a copy of pCopyMe. More...
 
 GMixedRelation (const GRelation *pCopyMe, size_t firstAttr, size_t attrCount)
 Makes a copy of the specified range of pCopyMe. More...
 
virtual ~GMixedRelation ()
 
void addAttr (size_t nValues)
 If nValues is zero, adds a real attribute. If nValues is

0, adds an attribute with "nValues" nominal values

More...
 
void addAttrs (size_t attrCount, size_t valueCount)
 Adds "attrCount" new attributes, each with "valueCount" values. (Use valueCount=0 for continuous attributes.) More...
 
void addAttrs (const GRelation &copyMe, size_t firstAttr=0, size_t attrCount=INVALID_INDEX)
 Copies the specified attributes and adds them to this relation. If attrCount < 0, then it will copy all attributes from firstAttr to the end. More...
 
virtual bool areContinuous (size_t first=0, size_t count=INVALID_INDEX) const
 Returns true iff all attributes in the specified range are continuous. More...
 
virtual bool areNominal (size_t first=0, size_t count=INVALID_INDEX) const
 Returns true iff all attributes in the specified range are nominal. More...
 
virtual GRelationclone () const
 Makes a deep copy of this relation. More...
 
virtual GRelationcloneMinimal () const
 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
 Makes a deep copy of the specified subset of this relation. More...
 
void copy (const GRelation *pCopyMe)
 Flushes this relation and then copies all of the attributes from pCopyMe. More...
 
virtual void copyAttr (const GRelation *pThat, size_t nAttr)
 Adds a copy of the specified attribute to this relation. More...
 
virtual void deleteAttributes (size_t nAttr, size_t count)
 Deletes an attribute. More...
 
virtual void flush ()
 Deletes all the attributes. More...
 
virtual GDomNodeserialize (GDom *pDoc) const
 Marshalls this object to a DOM, which can be saved to a variety of serial formats. More...
 
virtual void setAttrValueCount (size_t nAttr, size_t nValues)
 Sets the number of values for this attribute. More...
 
virtual size_t size () const
 Returns the total number of attributes in this relation. More...
 
virtual void swapAttributes (size_t nAttr1, size_t nAttr2)
 Swaps two columns. More...
 
virtual RelationType type () const
 Returns the type of relation. More...
 
virtual size_t valueCount (size_t nAttr) const
 Returns the number of nominal values in the specified attribute. 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...
 
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...
 

Protected Attributes

std::vector< size_t > m_valueCounts
 

Additional Inherited Members

- Public Types inherited from GClasses::GRelation
- Static Public Member Functions inherited from GClasses::GRelation
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...
 

Constructor & Destructor Documentation

GClasses::GMixedRelation::GMixedRelation ( )

Makes an empty relation.

GClasses::GMixedRelation::GMixedRelation ( std::vector< size_t > &  attrValues)

Construct a mixed relation. attrValues specifies the number of nominal values in each attribute (column), or 0 for continuous attributes.

GClasses::GMixedRelation::GMixedRelation ( const GDomNode pNode)

Loads from a DOM.

GClasses::GMixedRelation::GMixedRelation ( const GRelation pCopyMe)

Makes a copy of pCopyMe.

GClasses::GMixedRelation::GMixedRelation ( const GRelation pCopyMe,
size_t  firstAttr,
size_t  attrCount 
)

Makes a copy of the specified range of pCopyMe.

virtual GClasses::GMixedRelation::~GMixedRelation ( )
virtual

Member Function Documentation

void GClasses::GMixedRelation::addAttr ( size_t  nValues)

If nValues is zero, adds a real attribute. If nValues is

0, adds an attribute with "nValues" nominal values

void GClasses::GMixedRelation::addAttrs ( size_t  attrCount,
size_t  valueCount 
)

Adds "attrCount" new attributes, each with "valueCount" values. (Use valueCount=0 for continuous attributes.)

void GClasses::GMixedRelation::addAttrs ( const GRelation copyMe,
size_t  firstAttr = 0,
size_t  attrCount = INVALID_INDEX 
)

Copies the specified attributes and adds them to this relation. If attrCount < 0, then it will copy all attributes from firstAttr to the end.

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

Returns true iff all attributes in the specified range are continuous.

Implements GClasses::GRelation.

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

Returns true iff all attributes in the specified range are nominal.

Implements GClasses::GRelation.

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

Makes a deep copy of this relation.

Implements GClasses::GRelation.

Reimplemented in GClasses::GArffRelation.

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

Implements GClasses::GRelation.

Reimplemented in GClasses::GArffRelation.

virtual GRelation* GClasses::GMixedRelation::cloneSub ( size_t  start,
size_t  count 
) const
virtual

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

Implements GClasses::GRelation.

Reimplemented in GClasses::GArffRelation.

void GClasses::GMixedRelation::copy ( const GRelation pCopyMe)

Flushes this relation and then copies all of the attributes from pCopyMe.

virtual void GClasses::GMixedRelation::copyAttr ( const GRelation pThat,
size_t  nAttr 
)
virtual

Adds a copy of the specified attribute to this relation.

Reimplemented in GClasses::GArffRelation.

virtual void GClasses::GMixedRelation::deleteAttributes ( size_t  nAttr,
size_t  count 
)
virtual

Deletes an attribute.

Implements GClasses::GRelation.

Reimplemented in GClasses::GArffRelation.

virtual void GClasses::GMixedRelation::flush ( )
virtual

Deletes all the attributes.

Reimplemented in GClasses::GArffRelation.

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

Marshalls this object to a DOM, which can be saved to a variety of serial formats.

Implements GClasses::GRelation.

Reimplemented in GClasses::GArffRelation.

virtual void GClasses::GMixedRelation::setAttrValueCount ( size_t  nAttr,
size_t  nValues 
)
virtual

Sets the number of values for this attribute.

Reimplemented in GClasses::GArffRelation.

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

Returns the total number of attributes in this relation.

Implements GClasses::GRelation.

virtual void GClasses::GMixedRelation::swapAttributes ( size_t  nAttr1,
size_t  nAttr2 
)
virtual

Swaps two columns.

Implements GClasses::GRelation.

Reimplemented in GClasses::GArffRelation.

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

Returns the type of relation.

Implements GClasses::GRelation.

Reimplemented in GClasses::GArffRelation.

virtual size_t GClasses::GMixedRelation::valueCount ( size_t  nAttr) const
inlinevirtual

Returns the number of nominal values in the specified attribute.

Implements GClasses::GRelation.

Member Data Documentation

std::vector<size_t> GClasses::GMixedRelation::m_valueCounts
protected