GClasses
GClasses::GIncrementalTransform Class Referenceabstract

Detailed Description

This is the base class of algorithms that can transform data one row at a time without supervision.

#include <GTransform.h>

Inheritance diagram for GClasses::GIncrementalTransform:
GClasses::GTransform GClasses::GAttributeSelector GClasses::GDataAugmenter GClasses::GDiscretize GClasses::GImputeMissingVals GClasses::GIncrementalTransformChainer GClasses::GLogify GClasses::GNoiseGenerator GClasses::GNominalToCat GClasses::GNormalize GClasses::GPairProduct GClasses::GPCA GClasses::GReservoir GClasses::GSelfOrganizingMap

Public Member Functions

 GIncrementalTransform ()
 
 GIncrementalTransform (const GDomNode *pNode)
 
virtual ~GIncrementalTransform ()
 
const GRelation & after () const
 Returns a relation object describing the data after it is transformed. More...
 
const GRelation & before () const
 Returns a relation object describing the data before it is transformed. More...
 
GVec & innerBuf ()
 Returns a buffer of sufficient size to store an inner (transformed) vector. The caller should not to delete the buffer. The same buffer will be returned each time. More...
 
virtual GMatrix * reduce (const GMatrix &in)
 This calls train, then calls transformBatch, and returns the result. More...
 
virtual GDomNode * serialize (GDom *pDoc) const =0
 Marshal this object into a DOM, which can then be converted to a variety of serial formats. More...
 
void setAfter (GRelation *pRel)
 Sets the after relation. Takes ownership of pRel. More...
 
void setBefore (GRelation *pRel)
 Sets the before relation. Takes ownership of pRel. More...
 
void train (const GMatrix &data)
 Trains the transform on the data in pData. (This method may be a no-op for transformations that always behave in the same manner.) More...
 
void train (const GRelation &pRelation)
 "Trains" the transform without any data. More...
 
virtual void transform (const GVec &in, GVec &out)=0
 pIn is the source row. pOut is a buffer that will hold the transformed row. train must be called before this method is used More...
 
virtual GMatrix * transformBatch (const GMatrix &in)
 This assumes that train has already been called, and transforms all the rows in in returning the resulting matrix. The caller is responsible for deleting the new matrix. More...
 
virtual void untransform (const GVec &in, GVec &out)=0
 pIn is a previously transformed row, and pOut is a buffer that will hold the untransformed row. train must be called before this method is used. This method may throw an exception if this transformation cannot be undone or approximately undone. More...
 
virtual std::unique_ptr< GMatrix > untransformBatch (const GMatrix &in)
 This assumes train was previously called, and untransforms all the rows in pIn and returns the results. More...
 
virtual void untransformToDistribution (const GVec &in, GPrediction *pOut)=0
 Similar to untransform, except it produces a distribution instead of just a vector. This method may not be implemented in all classes, so it may throw an exception. More...
 
- Public Member Functions inherited from GClasses::GTransform
 GTransform ()
 
 GTransform (const GDomNode *pNode)
 
virtual ~GTransform ()
 

Static Public Member Functions

static void test ()
 Performs unit tests for this class. Throws an exception if there is a failure. More...
 

Protected Member Functions

virtual GDomNode * baseDomNode (GDom *pDoc, const char *szClassName) const
 Child classes should use this in their implementation of serialize. More...
 
virtual GRelation * trainInner (const GMatrix &data)=0
 This method implements the functionality called by train. The data passed in may be used to guide training. This method returns a smart-pointer to a relation the represents the form that the data will take after it is transformed. More...
 
virtual GRelation * trainInner (const GRelation &relation)=0
 This method implements the functionality called by train. This method is called to initialize the transform when it is used with an incremental learner. Transforms that cannot be trained without available data may throw an exception in this method. The relation passed in represents the form that the input data will have. This method returns a smart-pointer to a relation the represents the form that the data will take after it is transformed. More...
 

Constructor & Destructor Documentation

GClasses::GIncrementalTransform::GIncrementalTransform ( )
inline
GClasses::GIncrementalTransform::GIncrementalTransform ( const GDomNode *  pNode)
virtual GClasses::GIncrementalTransform::~GIncrementalTransform ( )
virtual

Member Function Documentation

const GRelation& GClasses::GIncrementalTransform::after ( ) const
inline

Returns a relation object describing the data after it is transformed.

train must be called before this method is used

virtual GDomNode* GClasses::GIncrementalTransform::baseDomNode ( GDom *  pDoc,
const char *  szClassName 
) const
protectedvirtual

Child classes should use this in their implementation of serialize.

Reimplemented from GClasses::GTransform.

const GRelation& GClasses::GIncrementalTransform::before ( ) const
inline

Returns a relation object describing the data before it is transformed.

train must be called before this method is used

GVec& GClasses::GIncrementalTransform::innerBuf ( )

Returns a buffer of sufficient size to store an inner (transformed) vector. The caller should not to delete the buffer. The same buffer will be returned each time.

virtual GMatrix* GClasses::GIncrementalTransform::reduce ( const GMatrix &  in)
virtual

This calls train, then calls transformBatch, and returns the result.

Implements GClasses::GTransform.

Reimplemented in GClasses::GSelfOrganizingMap.

virtual GDomNode* GClasses::GIncrementalTransform::serialize ( GDom *  pDoc) const
pure virtual
void GClasses::GIncrementalTransform::setAfter ( GRelation *  pRel)

Sets the after relation. Takes ownership of pRel.

void GClasses::GIncrementalTransform::setBefore ( GRelation *  pRel)

Sets the before relation. Takes ownership of pRel.

static void GClasses::GIncrementalTransform::test ( )
static

Performs unit tests for this class. Throws an exception if there is a failure.

void GClasses::GIncrementalTransform::train ( const GMatrix &  data)

Trains the transform on the data in pData. (This method may be a no-op for transformations that always behave in the same manner.)

void GClasses::GIncrementalTransform::train ( const GRelation &  pRelation)

"Trains" the transform without any data.

This method is called to initialize the transform when it is used with an incremental learner. Transforms that cannot be trained without available data may throw an exception in this method.

virtual GRelation* GClasses::GIncrementalTransform::trainInner ( const GMatrix &  data)
protectedpure virtual

This method implements the functionality called by train. The data passed in may be used to guide training. This method returns a smart-pointer to a relation the represents the form that the data will take after it is transformed.

Implemented in GClasses::GSelfOrganizingMap, GClasses::GLogify, GClasses::GImputeMissingVals, GClasses::GDiscretize, GClasses::GNormalize, GClasses::GNominalToCat, GClasses::GAttributeSelector, GClasses::GDataAugmenter, GClasses::GReservoir, GClasses::GPairProduct, GClasses::GNoiseGenerator, GClasses::GPCA, and GClasses::GIncrementalTransformChainer.

virtual GRelation* GClasses::GIncrementalTransform::trainInner ( const GRelation &  relation)
protectedpure virtual

This method implements the functionality called by train. This method is called to initialize the transform when it is used with an incremental learner. Transforms that cannot be trained without available data may throw an exception in this method. The relation passed in represents the form that the input data will have. This method returns a smart-pointer to a relation the represents the form that the data will take after it is transformed.

Implemented in GClasses::GSelfOrganizingMap, GClasses::GLogify, GClasses::GImputeMissingVals, GClasses::GDiscretize, GClasses::GNormalize, GClasses::GNominalToCat, GClasses::GAttributeSelector, GClasses::GDataAugmenter, GClasses::GReservoir, GClasses::GPairProduct, GClasses::GNoiseGenerator, GClasses::GPCA, and GClasses::GIncrementalTransformChainer.

virtual void GClasses::GIncrementalTransform::transform ( const GVec &  in,
GVec &  out 
)
pure virtual
virtual GMatrix* GClasses::GIncrementalTransform::transformBatch ( const GMatrix &  in)
virtual

This assumes that train has already been called, and transforms all the rows in in returning the resulting matrix. The caller is responsible for deleting the new matrix.

Reimplemented in GClasses::GImputeMissingVals.

virtual void GClasses::GIncrementalTransform::untransform ( const GVec &  in,
GVec &  out 
)
pure virtual

pIn is a previously transformed row, and pOut is a buffer that will hold the untransformed row. train must be called before this method is used. This method may throw an exception if this transformation cannot be undone or approximately undone.

Implemented in GClasses::GSelfOrganizingMap, GClasses::GLogify, GClasses::GImputeMissingVals, GClasses::GDiscretize, GClasses::GNormalize, GClasses::GNominalToCat, GClasses::GAttributeSelector, GClasses::GDataAugmenter, GClasses::GReservoir, GClasses::GPairProduct, GClasses::GNoiseGenerator, GClasses::GPCA, and GClasses::GIncrementalTransformChainer.

virtual std::unique_ptr<GMatrix> GClasses::GIncrementalTransform::untransformBatch ( const GMatrix &  in)
virtual

This assumes train was previously called, and untransforms all the rows in pIn and returns the results.

virtual void GClasses::GIncrementalTransform::untransformToDistribution ( const GVec &  in,
GPrediction *  pOut 
)
pure virtual

Similar to untransform, except it produces a distribution instead of just a vector. This method may not be implemented in all classes, so it may throw an exception.

Implemented in GClasses::GSelfOrganizingMap, GClasses::GLogify, GClasses::GImputeMissingVals, GClasses::GDiscretize, GClasses::GNormalize, GClasses::GNominalToCat, GClasses::GAttributeSelector, GClasses::GDataAugmenter, GClasses::GReservoir, GClasses::GPairProduct, GClasses::GNoiseGenerator, GClasses::GPCA, and GClasses::GIncrementalTransformChainer.