GClasses

GClasses::GNominalToCat Class Reference

This is sort-of the opposite of discretize. It converts each nominal attribute to a categorical distribution by representing each value using the corresponding row of the identity matrix. For example, if a certain nominal attribute has 4 possible values, then a value of 3 would be encoded as the vector 0 0 1 0. When predictions are converted back to nominal values, the mode of the categorical distribution is used as the predicted value. (This is similar to Weka's NominalToBinaryFilter.) More...

#include <GTransform.h>

Inheritance diagram for GClasses::GNominalToCat:
GClasses::GTwoWayIncrementalTransform GClasses::GIncrementalTransform GClasses::GTransform

List of all members.

Public Member Functions

 GNominalToCat (size_t valueCap=12)
 GNominalToCat (GDomNode *pNode, GLearnerLoader &ll)
 Load from a DOM.
virtual ~GNominalToCat ()
virtual GDomNodeserialize (GDom *pDoc)
 Marshal this object into a DOM, which can then be converted to a variety of serial formats.
virtual void train (GMatrix &data)
 See the comment for GIncrementalTransform::train.
virtual void transform (const double *pIn, double *pOut)
 See the comment for GIncrementalTransform::transform.
virtual void untransform (const double *pIn, double *pOut)
 See the comment for GTwoWayIncrementalTransform::untransform.
virtual void untransformToDistribution (const double *pIn, GPrediction *pOut)
 See the comment for GTwoWayIncrementalTransform::untransformToDistribution.
void reverseAttrMap (std::vector< size_t > &rmap)
 Makes a mapping from the post-transform attribute indexes to the pre-transform attribute indexes.
void preserveUnknowns ()
 Specify to preserve unknown values. That is, an unknown nominal value will be converted to a distribution of all unknown real values.

Protected Member Functions

void init (sp_relation &pRelationBefore)

Protected Attributes

size_t m_valueCap
GRandm_pRand
std::vector< size_t > m_ranks
bool m_preserveUnknowns

Detailed Description

This is sort-of the opposite of discretize. It converts each nominal attribute to a categorical distribution by representing each value using the corresponding row of the identity matrix. For example, if a certain nominal attribute has 4 possible values, then a value of 3 would be encoded as the vector 0 0 1 0. When predictions are converted back to nominal values, the mode of the categorical distribution is used as the predicted value. (This is similar to Weka's NominalToBinaryFilter.)


Constructor & Destructor Documentation

GClasses::GNominalToCat::GNominalToCat ( size_t  valueCap = 12)
GClasses::GNominalToCat::GNominalToCat ( GDomNode pNode,
GLearnerLoader ll 
)

Load from a DOM.

virtual GClasses::GNominalToCat::~GNominalToCat ( ) [virtual]

Member Function Documentation

void GClasses::GNominalToCat::init ( sp_relation pRelationBefore) [protected]
void GClasses::GNominalToCat::preserveUnknowns ( ) [inline]

Specify to preserve unknown values. That is, an unknown nominal value will be converted to a distribution of all unknown real values.

void GClasses::GNominalToCat::reverseAttrMap ( std::vector< size_t > &  rmap)

Makes a mapping from the post-transform attribute indexes to the pre-transform attribute indexes.

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

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

Implements GClasses::GIncrementalTransform.

virtual void GClasses::GNominalToCat::train ( GMatrix data) [virtual]
virtual void GClasses::GNominalToCat::transform ( const double *  pIn,
double *  pOut 
) [virtual]
virtual void GClasses::GNominalToCat::untransform ( const double *  pIn,
double *  pOut 
) [virtual]
virtual void GClasses::GNominalToCat::untransformToDistribution ( const double *  pIn,
GPrediction pOut 
) [virtual]

Member Data Documentation

std::vector<size_t> GClasses::GNominalToCat::m_ranks [protected]