GClasses

GClasses::GRelation Class Reference

Holds the metadata for a dataset, including which attributes are continuous or nominal, and how many values each nominal attribute supports. More...

#include <GMatrix.h>

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

List of all members.

Public Types

enum  RelationType { UNIFORM, MIXED, ARFF }

Public Member Functions

 GRelation ()
virtual ~GRelation ()
virtual RelationType type ()=0
 Returns the type of relation.
virtual GDomNodeserialize (GDom *pDoc)=0
 Marshal this object into a DOM, which can then be converted to a variety of serial formats.
virtual size_t size ()=0
 Returns the number of attributes (columns)
virtual size_t valueCount (size_t nAttr)=0
 Returns the number of values in the specified attribute. (Returns 0 for continuous attributes.)
virtual bool areContinuous (size_t first, size_t count)=0
 Returns true of all of the attributes in the specified range are continuous.
virtual bool areNominal (size_t first, size_t count)=0
 Returns true of all of the attributes in the specified range are nominal.
virtual GRelationclone ()=0
 Makes a deep copy of this relation.
virtual GRelationcloneSub (size_t start, size_t count)=0
 Makes a deep copy of the specified subset of this relation.
virtual void deleteAttribute (size_t index)=0
 Deletes the specified attribute.
virtual void swapAttributes (size_t nAttr1, size_t nAttr2)=0
 Swaps two attributes.
void print (std::ostream &stream, GMatrix *pData, size_t precision)
 Prints as an ARFF file to the specified stream. (pData can be NULL if data is not available)
virtual void printAttrName (std::ostream &stream, size_t column)
 Prints the specified attribute name to a stream.
virtual void printAttrValue (std::ostream &stream, size_t column, double value)
 Prints the specified value to a stream.
virtual bool isCompatible (GRelation &that)
 Returns true iff this and that have the same number of values for each attribute.
void printRow (std::ostream &stream, double *pRow, const char *separator)
 Print a single row of data in ARFF format.
size_t countRealSpaceDims (size_t nFirstAttr, size_t nAttrCount)
 Counts the size of the corresponding real-space vector.
void toRealSpace (const double *pIn, double *pOut, size_t nFirstAttr, size_t nAttrCount)
 Converts a row (pIn) to a real-space vector (pOut) (pIn should point to the nFirstAttr'th element, not the first element)
void fromRealSpace (const double *pIn, double *pOut, size_t nFirstAttr, size_t nAttrCount, GRand *pRand)
 Converts a real-space vector (pIn) to a row (pOut) nFirstAttr and nAttrCount refer to the row indexes.
void fromRealSpace (const double *pIn, GPrediction *pOut, size_t nFirstAttr, size_t nAttrCount)
 Converts a real-space vector (pIn) to an array of predictions (pOut) nFirstAttr and nAttrCount refer to the prediction indexes.
void save (GMatrix *pData, const char *szFilename, size_t precision)
 Saves to a file.

Static Public Member Functions

static smart_ptr< GRelationdeserialize (GDomNode *pNode)
 Load from a DOM.
static void test ()
 Performs unit tests for this class. Throws an exception if there is a failure.

Static Protected Member Functions

static std::string quote (const std::string aString)
 Returns a copy of aString modified to escape internal instances of comma, apostrophe, space, percent, back-slash, and double-quote.

Detailed Description

Holds the metadata for a dataset, including 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 ( ) [inline, virtual]

Member Function Documentation

virtual bool GClasses::GRelation::areContinuous ( size_t  first,
size_t  count 
) [pure virtual]

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

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

virtual bool GClasses::GRelation::areNominal ( size_t  first,
size_t  count 
) [pure virtual]

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

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

virtual GRelation* GClasses::GRelation::clone ( ) [pure virtual]

Makes a deep copy of this relation.

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

virtual GRelation* GClasses::GRelation::cloneSub ( size_t  start,
size_t  count 
) [pure virtual]

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

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

size_t GClasses::GRelation::countRealSpaceDims ( size_t  nFirstAttr,
size_t  nAttrCount 
)

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::GUniformRelation, GClasses::GMixedRelation, and GClasses::GArffRelation.

static smart_ptr<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 
)

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 
)

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 ( GRelation that) [virtual]

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

Reimplemented in GClasses::GUniformRelation, and GClasses::GArffRelation.

void GClasses::GRelation::print ( std::ostream &  stream,
GMatrix pData,
size_t  precision 
)

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 
) [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 
) [virtual]

Prints the specified value to a stream.

Reimplemented in GClasses::GArffRelation.

void GClasses::GRelation::printRow ( std::ostream &  stream,
double *  pRow,
const char *  separator 
)

Print a single row of data in ARFF format.

static std::string GClasses::GRelation::quote ( const std::string  aString) [static, protected]

Returns a copy of aString modified to escape internal instances of comma, apostrophe, space, percent, back-slash, and double-quote.

void GClasses::GRelation::save ( GMatrix pData,
const char *  szFilename,
size_t  precision 
)

Saves to a file.

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

Marshal this object into a DOM, which can then be converted to a variety of serial formats.

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

virtual size_t GClasses::GRelation::size ( ) [pure virtual]

Returns the number of attributes (columns)

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

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 
)

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 ( ) [pure virtual]

Returns the type of relation.

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

virtual size_t GClasses::GRelation::valueCount ( size_t  nAttr) [pure virtual]

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

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