mlpack
Public Types | Public Member Functions | List of all members
mlpack::tree::HoeffdingTreeModel Class Reference

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

#include <hoeffding_tree_model.hpp>

Public Types

enum  TreeType { GINI_HOEFFDING, GINI_BINARY, INFO_HOEFFDING, INFO_BINARY }
 This enumerates the four types of trees we can hold.
 
typedef HoeffdingTree< GiniImpurity, HoeffdingDoubleNumericSplit, HoeffdingCategoricalSplitGiniHoeffdingTreeType
 Convenience typedef for GINI_HOEFFDING tree type.
 
typedef HoeffdingTree< GiniImpurity, BinaryDoubleNumericSplit, HoeffdingCategoricalSplitGiniBinaryTreeType
 Convenience typedef for GINI_BINARY tree type.
 
typedef HoeffdingTree< HoeffdingInformationGain, HoeffdingDoubleNumericSplit, HoeffdingCategoricalSplitInfoHoeffdingTreeType
 Convenience typedef for INFO_HOEFFDING tree type.
 
typedef HoeffdingTree< HoeffdingInformationGain, BinaryDoubleNumericSplit, HoeffdingCategoricalSplitInfoBinaryTreeType
 Convenience typedef for INFO_BINARY tree type.
 

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...
 
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...
 
 ~HoeffdingTreeModel ()
 Clean up the given model.
 
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 Train (const arma::mat &dataset, const arma::Row< size_t > &labels, const bool batchTraining)
 Train in streaming mode on the given dataset. 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.
 
template<typename Archive >
void serialize (Archive &ar, const uint32_t)
 Serialize the model.
 

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.

Constructor & Destructor Documentation

◆ HoeffdingTreeModel() [1/3]

HoeffdingTreeModel::HoeffdingTreeModel ( const TreeType type = GINI_HOEFFDING)

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]

HoeffdingTreeModel::HoeffdingTreeModel ( const HoeffdingTreeModel other)

Copy the Hoeffding tree model from the given other model.

Parameters
otherHoeffding tree model to copy.

◆ HoeffdingTreeModel() [3/3]

HoeffdingTreeModel::HoeffdingTreeModel ( HoeffdingTreeModel &&  other)

Move the Hoeffding tree model from the given other model.

Parameters
otherHoeffding tree model to move.

Member Function Documentation

◆ BuildModel()

void HoeffdingTreeModel::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 HoeffdingTreeModel::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 HoeffdingTreeModel::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.

◆ operator=() [1/2]

HoeffdingTreeModel & 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 & HoeffdingTreeModel::operator= ( HoeffdingTreeModel &&  other)

Move the Hoeffding tree model from the given other model.

Parameters
otherHoeffding tree model to move.

◆ Train()

void HoeffdingTreeModel::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 files: