GClasses
GClasses::GAgglomerativeTransducer Class Reference

Detailed Description

This is a semi-supervised agglomerative clusterer. It can only handle one output, and it must be nominal. All inputs must be continuous. Also, it assumes that all output values are represented in the training set.

#include <GCluster.h>

Inheritance diagram for GClasses::GAgglomerativeTransducer:
GClasses::GTransducer

Public Member Functions

 GAgglomerativeTransducer ()
 
virtual ~GAgglomerativeTransducer ()
 
void autoTune (GMatrix &features, GMatrix &labels)
 This model has no parameters to tune, so this method is a noop. More...
 
void setMetric (GDistanceMetric *pMetric, bool own)
 Specify the metric to use to determine the distance between points. If own is true, then this object will take care to delete pMetric. More...
 
- Public Member Functions inherited from GClasses::GTransducer
 GTransducer ()
 General-purpose constructor. More...
 
 GTransducer (const GTransducer &that)
 Copy-constructor. Throws an exception to prevent models from being copied by value. More...
 
virtual ~GTransducer ()
 
virtual bool canGeneralize ()
 Returns false because semi-supervised learners have no internal model, so they can't evaluate previously unseen rows. More...
 
virtual bool canImplicitlyHandleContinuousFeatures ()
 Returns true iff this algorithm can implicitly handle continuous features. If it cannot, then the GDiscretize transform will be used to convert continuous features to nominal values before passing them to it. More...
 
virtual bool canImplicitlyHandleMissingFeatures ()
 Returns true iff this algorithm supports missing feature values. If it cannot, then an imputation filter will be used to predict missing values before any feature-vectors are passed to the algorithm. More...
 
virtual bool canImplicitlyHandleNominalFeatures ()
 Returns true iff this algorithm can implicitly handle nominal features. If it cannot, then the GNominalToCat transform will be used to convert nominal features to continuous values before passing them to it. More...
 
virtual bool canImplicitlyHandleNominalLabels ()
 Returns true iff this algorithm can implicitly handle nominal labels (a.k.a. classification). If it cannot, then the GNominalToCat transform will be used during training to convert nominal labels to continuous values, and to convert categorical predictions back to nominal labels. More...
 
virtual bool canTrainIncrementally ()
 Returns false because semi-supervised learners cannot be trained incrementally. More...
 
double crossValidate (const GMatrix &features, const GMatrix &labels, size_t nFolds, double *pOutSAE=NULL, RepValidateCallback pCB=NULL, size_t nRep=0, void *pThis=NULL)
 Perform n-fold cross validation on pData. Returns sum-squared error. Uses trainAndTest for each fold. pCB is an optional callback method for reporting intermediate stats. It can be NULL if you don't want intermediate reporting. nRep is just the rep number that will be passed to the callback. pThis is just a pointer that will be passed to the callback for you to use however you want. It doesn't affect this method. if pOutSAE is not NULL, the sum absolute error will be placed there. More...
 
GTransduceroperator= (const GTransducer &other)
 Throws an exception to prevent models from being copied by value. More...
 
GRandrand ()
 Returns a reference to the random number generator associated with this object. For example, you could use it to change the random seed, to make this algorithm behave differently. This might be important, for example, in an ensemble of learners. More...
 
double repValidate (const GMatrix &features, const GMatrix &labels, size_t reps, size_t nFolds, double *pOutSAE=NULL, RepValidateCallback pCB=NULL, void *pThis=NULL)
 Perform cross validation "nReps" times and return the average score. pCB is an optional callback method for reporting intermediate stats It can be NULL if you don't want intermediate reporting. pThis is just a pointer that will be passed to the callback for you to use however you want. It doesn't affect this method. if pOutSAE is not NULL, the sum absolute error will be placed there. More...
 
virtual bool supportedFeatureRange (double *pOutMin, double *pOutMax)
 Returns true if this algorithm supports any feature value, or if it does not implicitly handle continuous features. If a limited range of continuous values is supported, returns false and sets pOutMin and pOutMax to specify the range. More...
 
virtual bool supportedLabelRange (double *pOutMin, double *pOutMax)
 Returns true if this algorithm supports any label value, or if it does not implicitly handle continuous labels. If a limited range of continuous values is supported, returns false and sets pOutMin and pOutMax to specify the range. More...
 
virtual double trainAndTest (const GMatrix &trainFeatures, const GMatrix &trainLabels, const GMatrix &testFeatures, const GMatrix &testLabels, double *pOutSAE=NULL)
 Trains and tests this learner. Returns the sum-squared-error. if pOutSAE is not NULL, the sum absolute error will be placed there. More...
 
std::unique_ptr< GMatrixtransduce (const GMatrix &features1, const GMatrix &labels1, const GMatrix &features2)
 Predicts a set of labels to correspond with features2, such that these labels will be consistent with the patterns exhibited by features1 and labels1. More...
 
void transductiveConfusionMatrix (const GMatrix &trainFeatures, const GMatrix &trainLabels, const GMatrix &testFeatures, const GMatrix &testLabels, std::vector< GMatrix * > &stats)
 Makes a confusion matrix for a transduction algorithm. More...
 

Protected Member Functions

virtual bool canImplicitlyHandleContinuousLabels ()
 See the comment for GTransducer::canImplicitlyHandleContinuousLabels. More...
 
virtual std::unique_ptr< GMatrixtransduceInner (const GMatrix &features1, const GMatrix &labels1, const GMatrix &features2)
 See the comment for GTransducer::transduce. Throws if labels1 has more than one column. More...
 

Protected Attributes

bool m_ownMetric
 
GDistanceMetricm_pMetric
 
- Protected Attributes inherited from GClasses::GTransducer
GRand m_rand
 

Constructor & Destructor Documentation

GClasses::GAgglomerativeTransducer::GAgglomerativeTransducer ( )
virtual GClasses::GAgglomerativeTransducer::~GAgglomerativeTransducer ( )
virtual

Member Function Documentation

void GClasses::GAgglomerativeTransducer::autoTune ( GMatrix features,
GMatrix labels 
)

This model has no parameters to tune, so this method is a noop.

virtual bool GClasses::GAgglomerativeTransducer::canImplicitlyHandleContinuousLabels ( )
inlineprotectedvirtual
void GClasses::GAgglomerativeTransducer::setMetric ( GDistanceMetric pMetric,
bool  own 
)

Specify the metric to use to determine the distance between points. If own is true, then this object will take care to delete pMetric.

virtual std::unique_ptr<GMatrix> GClasses::GAgglomerativeTransducer::transduceInner ( const GMatrix features1,
const GMatrix labels1,
const GMatrix features2 
)
protectedvirtual

See the comment for GTransducer::transduce. Throws if labels1 has more than one column.

Implements GClasses::GTransducer.

Member Data Documentation

bool GClasses::GAgglomerativeTransducer::m_ownMetric
protected
GDistanceMetric* GClasses::GAgglomerativeTransducer::m_pMetric
protected