HoeffdingTreeModel Class Reference

This class is a serializable Hoeffding tree model that can hold four different types of Hoeffding trees. More...

Public Types

typedef HoeffdingTree< GiniImpurity, BinaryDoubleNumericSplit, HoeffdingCategoricalSplitGiniBinaryTreeType
 Convenience typedef for GINI_BINARY tree type. More...

 
typedef HoeffdingTree< GiniImpurity, HoeffdingDoubleNumericSplit, HoeffdingCategoricalSplitGiniHoeffdingTreeType
 Convenience typedef for GINI_HOEFFDING tree type. More...

 
typedef HoeffdingTree< InformationGain, BinaryDoubleNumericSplit, HoeffdingCategoricalSplitInfoBinaryTreeType
 Convenience typedef for INFO_BINARY tree type. More...

 
typedef HoeffdingTree< InformationGain, HoeffdingDoubleNumericSplit, HoeffdingCategoricalSplitInfoHoeffdingTreeType
 Convenience typedef for INFO_HOEFFDING tree type. More...

 
enum  TreeType
{
  GINI_HOEFFDING
,
  GINI_BINARY
,
  INFO_HOEFFDING
,
  INFO_BINARY

}
 This enumerates the four types of trees we can hold. More...

 

Public Member Functions

 HoeffdingTreeModel (const TreeType &type=GINI_HOEFFDING)
 Construct the Hoeffding tree model, but don't initialize any tree. More...

 
 HoeffdingTreeModel (const HoeffdingTreeModel &other)
 Copy the Hoeffding tree model from the given other model. More...

 
 HoeffdingTreeModel (HoeffdingTreeModel &&other)
 Move the Hoeffding tree model from the given other model. More...

 
 ~HoeffdingTreeModel ()
 Clean up the given model. More...

 
void BuildModel (const arma::mat &dataset, const data::DatasetInfo &datasetInfo, const arma::Row< size_t > &labels, const size_t numClasses, const bool batchTraining, const double successProbability, const size_t maxSamples, const size_t checkInterval, const size_t minSamples, const size_t bins, const size_t observationsBeforeBinning)
 Train the model on the given dataset with the given labels. More...

 
void Classify (const arma::mat &dataset, arma::Row< size_t > &predictions) const
 Using the model, classify the given test points. More...

 
void Classify (const arma::mat &dataset, arma::Row< size_t > &predictions, arma::rowvec &probabilities) const
 Using the model, classify the given test points, returning class probabilities. More...

 
size_t NumNodes () const
 Get the number of nodes in the tree. More...

 
HoeffdingTreeModeloperator= (const HoeffdingTreeModel &other)
 Copy the Hoeffding tree model from the given other model. More...

 
HoeffdingTreeModeloperator= (HoeffdingTreeModel &&other)
 Move the Hoeffding tree model from the given other model. More...

 
template
<
typename
Archive
>
void serialize (Archive &ar, const unsigned int)
 Serialize the model. More...

 
void Train (const arma::mat &dataset, const arma::Row< size_t > &labels, const bool batchTraining)
 Train in streaming mode on the given dataset. More...

 

Detailed Description

This class is a serializable Hoeffding tree model that can hold four different types of Hoeffding trees.

It is meant to be used by the command-line program for Hoeffding trees.

Definition at line 27 of file hoeffding_tree_model.hpp.

Member Typedef Documentation

◆ GiniBinaryTreeType

Convenience typedef for GINI_BINARY tree type.

Definition at line 44 of file hoeffding_tree_model.hpp.

◆ GiniHoeffdingTreeType

Convenience typedef for GINI_HOEFFDING tree type.

Definition at line 41 of file hoeffding_tree_model.hpp.

◆ InfoBinaryTreeType

Convenience typedef for INFO_BINARY tree type.

Definition at line 50 of file hoeffding_tree_model.hpp.

◆ InfoHoeffdingTreeType

Convenience typedef for INFO_HOEFFDING tree type.

Definition at line 47 of file hoeffding_tree_model.hpp.

Member Enumeration Documentation

◆ TreeType

enum TreeType

This enumerates the four types of trees we can hold.

Enumerator
GINI_HOEFFDING 
GINI_BINARY 
INFO_HOEFFDING 
INFO_BINARY 

Definition at line 31 of file hoeffding_tree_model.hpp.

Constructor & Destructor Documentation

◆ HoeffdingTreeModel() [1/3]

Construct the Hoeffding tree model, but don't initialize any tree.

Be sure to call Train() before doing anything with the model!

Parameters
typeType of tree that will be used.

◆ HoeffdingTreeModel() [2/3]

Copy the Hoeffding tree model from the given other model.

Parameters
otherHoeffding tree model to copy.

◆ HoeffdingTreeModel() [3/3]

Move the Hoeffding tree model from the given other model.

Parameters
otherHoeffding tree model to move.

◆ ~HoeffdingTreeModel()

Clean up the given model.

Member Function Documentation

◆ BuildModel()

void BuildModel ( const arma::mat &  dataset,
const data::DatasetInfo datasetInfo,
const arma::Row< size_t > &  labels,
const size_t  numClasses,
const bool  batchTraining,
const double  successProbability,
const size_t  maxSamples,
const size_t  checkInterval,
const size_t  minSamples,
const size_t  bins,
const size_t  observationsBeforeBinning 
)

Train the model on the given dataset with the given labels.

This method just passes to the appropriate HoeffdingTree<...> constructor, and will train with one pass over the dataset.

Parameters
datasetDataset to train on.
datasetInfoInformation about dimensions of dataset.
labelsLabels for training set.
numClassesNumber of classes in dataset.
batchTrainingWhether or not to train in batch.
successProbabilityProbability of success required in Hoeffding bound before a split can happen.
maxSamplesMaximum number of samples before a split is forced.
checkIntervalNumber of samples required before each split check.
minSamplesIf the node has seen this many points or fewer, no split will be allowed.
binsNumber of bins, for Hoeffding numeric split.
observationsBeforeBinningNumber of observations before binning, for Hoeffding numeric split.

◆ Classify() [1/2]

void Classify ( const arma::mat &  dataset,
arma::Row< size_t > &  predictions 
) const

Using the model, classify the given test points.

Be sure that BuildModel() has been called first!

Parameters
datasetDataset to classify.
predictionsVector to store predictions for test points in.

◆ Classify() [2/2]

void Classify ( const arma::mat &  dataset,
arma::Row< size_t > &  predictions,
arma::rowvec &  probabilities 
) const

Using the model, classify the given test points, returning class probabilities.

Parameters
datasetDataset to classify.
predictionsVector to store predictions for test points in.
probabilitiesVector to store probabilities for test points in.

◆ NumNodes()

size_t NumNodes ( ) const

Get the number of nodes in the tree.

◆ operator=() [1/2]

HoeffdingTreeModel& operator= ( const HoeffdingTreeModel other)

Copy the Hoeffding tree model from the given other model.

Parameters
otherHoeffding tree model to copy.

◆ operator=() [2/2]

HoeffdingTreeModel& operator= ( HoeffdingTreeModel &&  other)

Move the Hoeffding tree model from the given other model.

Parameters
otherHoeffding tree model to move.

◆ serialize()

void serialize ( Archive &  ar,
const unsigned  int 
)
inline

◆ Train()

void Train ( const arma::mat &  dataset,
const arma::Row< size_t > &  labels,
const bool  batchTraining 
)

Train in streaming mode on the given dataset.

This takes one pass. Be sure that BuildModel() has been called first!

Parameters
datasetDataset to train on.
labelsLabels for training set.
batchTrainingWhether or not to train in batch.

The documentation for this class was generated from the following file: