GClasses
GClasses::GGraphCutTransducer Class Reference

Detailed Description

A transduction algorithm that uses a max-flow/min-cut graph-cut algorithm to partition the data until each class is in a separate cluster. Unlabeled points are then assigned the label of the cluster in which they fall.

#include <GCluster.h>

Inheritance diagram for GClasses::GGraphCutTransducer:
GClasses::GTransducer

Public Member Functions

 GGraphCutTransducer ()
 
virtual ~GGraphCutTransducer ()
 
void autoTune (GMatrix &features, GMatrix &labels)
 Uses cross-validation to find a set of parameters that works well with the provided data. More...
 
size_t neighbors ()
 Returns the number of neighbors to which each point is connected. More...
 
void setNeighbors (size_t k)
 Sets the number of neighbors to use to form the graph. The default is 12. 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. Only supports one-dimensional labels. More...
 

Protected Attributes

size_t m_neighborCount
 
- Protected Attributes inherited from GClasses::GTransducer
GRand m_rand
 

Constructor & Destructor Documentation

GClasses::GGraphCutTransducer::GGraphCutTransducer ( )
virtual GClasses::GGraphCutTransducer::~GGraphCutTransducer ( )
virtual

Member Function Documentation

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

Uses cross-validation to find a set of parameters that works well with the provided data.

virtual bool GClasses::GGraphCutTransducer::canImplicitlyHandleContinuousLabels ( )
inlineprotectedvirtual
size_t GClasses::GGraphCutTransducer::neighbors ( )
inline

Returns the number of neighbors to which each point is connected.

void GClasses::GGraphCutTransducer::setNeighbors ( size_t  k)

Sets the number of neighbors to use to form the graph. The default is 12.

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

See the comment for GTransducer::transduce. Only supports one-dimensional labels.

Implements GClasses::GTransducer.

Member Data Documentation

size_t GClasses::GGraphCutTransducer::m_neighborCount
protected