GClasses
GClasses::GDiscretize Class Reference

This transform uses buckets to convert continuous data into discrete data. It is common to use GFilter to combine this with your favorite modeler (which only supports discrete values) to create a modeler that can also support continuous values as well. More...

#include <GTransform.h>

Inheritance diagram for GClasses::GDiscretize:
GClasses::GIncrementalTransform GClasses::GTransform

Public Member Functions

 GDiscretize (size_t buckets=INVALID_INDEX)
 if buckets is less than 0, then it will use the floor of the square root of the number of rows in the data More...
 
 GDiscretize (GDomNode *pNode, GLearnerLoader &ll)
 Load from a DOM. More...
 
virtual ~GDiscretize ()
 
virtual GDomNodeserialize (GDom *pDoc) const
 Marshal this object into a DOM, which can then be converted to a variety of serial formats. More...
 
virtual void transform (const double *pIn, double *pOut)
 See the comment for GIncrementalTransform::transform. More...
 
virtual void untransform (const double *pIn, double *pOut)
 See the comment for GIncrementalTransform::untransform. More...
 
virtual void untransformToDistribution (const double *pIn, GPrediction *pOut)
 See the comment for GIncrementalTransform::untransformToDistribution. More...
 
- Public Member Functions inherited from GClasses::GIncrementalTransform
 GIncrementalTransform ()
 
 GIncrementalTransform (GDomNode *pNode, GLearnerLoader &ll)
 
virtual ~GIncrementalTransform ()
 
const GRelationafter () const
 Returns a relation object describing the data after it is transformed. More...
 
const GRelationbefore () const
 Returns a relation object describing the data before it is transformed. More...
 
double * 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 GMatrixreduce (const GMatrix &in)
 This calls train, then calls transformBatch, and returns the result. 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 GMatrixtransformBatch (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 GMatrixuntransformBatch (const GMatrix &in)
 This assumes train was previously called, and untransforms all the rows in pIn and returns the results. More...
 
- Public Member Functions inherited from GClasses::GTransform
 GTransform ()
 
 GTransform (GDomNode *pNode, GLearnerLoader &ll)
 
virtual ~GTransform ()
 

Protected Member Functions

virtual GRelationtrainInner (const GMatrix &data)
 See the comment for GIncrementalTransform::train. More...
 
virtual GRelationtrainInner (const GRelation &relation)
 Throws an exception (because this transform cannot be trained without data) More...
 
- Protected Member Functions inherited from GClasses::GIncrementalTransform
virtual GDomNodebaseDomNode (GDom *pDoc, const char *szClassName) const
 Child classes should use this in their implementation of serialize. More...
 

Protected Attributes

size_t m_bucketsIn
 
size_t m_bucketsOut
 
double * m_pMins
 
double * m_pRanges
 

Additional Inherited Members

- Static Public Member Functions inherited from GClasses::GIncrementalTransform
static void test ()
 Performs unit tests for this class. Throws an exception if there is a failure. More...
 

Detailed Description

This transform uses buckets to convert continuous data into discrete data. It is common to use GFilter to combine this with your favorite modeler (which only supports discrete values) to create a modeler that can also support continuous values as well.

Constructor & Destructor Documentation

GClasses::GDiscretize::GDiscretize ( size_t  buckets = INVALID_INDEX)

if buckets is less than 0, then it will use the floor of the square root of the number of rows in the data

GClasses::GDiscretize::GDiscretize ( GDomNode pNode,
GLearnerLoader ll 
)

Load from a DOM.

virtual GClasses::GDiscretize::~GDiscretize ( )
virtual

Member Function Documentation

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

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

Implements GClasses::GIncrementalTransform.

virtual GRelation* GClasses::GDiscretize::trainInner ( const GMatrix data)
protectedvirtual
virtual GRelation* GClasses::GDiscretize::trainInner ( const GRelation relation)
protectedvirtual

Throws an exception (because this transform cannot be trained without data)

Implements GClasses::GIncrementalTransform.

virtual void GClasses::GDiscretize::transform ( const double *  pIn,
double *  pOut 
)
virtual
virtual void GClasses::GDiscretize::untransform ( const double *  pIn,
double *  pOut 
)
virtual
virtual void GClasses::GDiscretize::untransformToDistribution ( const double *  pIn,
GPrediction pOut 
)
virtual

Member Data Documentation

size_t GClasses::GDiscretize::m_bucketsIn
protected
size_t GClasses::GDiscretize::m_bucketsOut
protected
double* GClasses::GDiscretize::m_pMins
protected
double* GClasses::GDiscretize::m_pRanges
protected