mlpack  master
Public Types | Public Member Functions | Private Attributes | 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...

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...
 

Private Attributes

GiniBinaryTreeTypeginiBinaryTree
 This is used if we are using the Gini impurity and the binary numeric split. More...
 
GiniHoeffdingTreeTypeginiHoeffdingTree
 This is used if we are using the Gini impurity and the Hoeffding numeric split. More...
 
InfoBinaryTreeTypeinfoBinaryTree
 This is used if we are using the information gain and the binary numeric split. More...
 
InfoHoeffdingTreeTypeinfoHoeffdingTree
 This is used if we are using the information gain and the Hoeffding numeric split. More...
 
TreeType type
 The type of tree we are using. 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 22 of file hoeffding_tree_model.hpp.

Member Typedef Documentation

Convenience typedef for GINI_BINARY tree type.

Definition at line 39 of file hoeffding_tree_model.hpp.

Convenience typedef for GINI_HOEFFDING tree type.

Definition at line 36 of file hoeffding_tree_model.hpp.

Convenience typedef for INFO_BINARY tree type.

Definition at line 45 of file hoeffding_tree_model.hpp.

Convenience typedef for INFO_HOEFFDING tree type.

Definition at line 42 of file hoeffding_tree_model.hpp.

Member Enumeration Documentation

This enumerates the four types of trees we can hold.

Enumerator
GINI_HOEFFDING 
GINI_BINARY 
INFO_HOEFFDING 
INFO_BINARY 

Definition at line 26 of file hoeffding_tree_model.hpp.

Constructor & Destructor Documentation

mlpack::tree::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.
mlpack::tree::HoeffdingTreeModel::HoeffdingTreeModel ( const HoeffdingTreeModel other)

Copy the Hoeffding tree model from the given other model.

Parameters
otherHoeffding tree model to copy.
mlpack::tree::HoeffdingTreeModel::HoeffdingTreeModel ( HoeffdingTreeModel &&  other)

Move the Hoeffding tree model from the given other model.

Parameters
otherHoeffding tree model to move.
mlpack::tree::HoeffdingTreeModel::~HoeffdingTreeModel ( )

Clean up the given model.

Member Function Documentation

void mlpack::tree::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.
void mlpack::tree::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.
void mlpack::tree::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.
size_t mlpack::tree::HoeffdingTreeModel::NumNodes ( ) const

Get the number of nodes in the tree.

HoeffdingTreeModel& mlpack::tree::HoeffdingTreeModel::operator= ( const HoeffdingTreeModel other)

Copy the Hoeffding tree model from the given other model.

Parameters
otherHoeffding tree model to copy.
HoeffdingTreeModel& mlpack::tree::HoeffdingTreeModel::operator= ( HoeffdingTreeModel &&  other)

Move the Hoeffding tree model from the given other model.

Parameters
otherHoeffding tree model to move.
template<typename Archive >
void mlpack::tree::HoeffdingTreeModel::Serialize ( Archive &  ar,
const unsigned  int 
)
inline
void mlpack::tree::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.

Member Data Documentation

GiniBinaryTreeType* mlpack::tree::HoeffdingTreeModel::giniBinaryTree
private

This is used if we are using the Gini impurity and the binary numeric split.

Definition at line 224 of file hoeffding_tree_model.hpp.

Referenced by Serialize().

GiniHoeffdingTreeType* mlpack::tree::HoeffdingTreeModel::giniHoeffdingTree
private

This is used if we are using the Gini impurity and the Hoeffding numeric split.

Definition at line 220 of file hoeffding_tree_model.hpp.

Referenced by Serialize().

InfoBinaryTreeType* mlpack::tree::HoeffdingTreeModel::infoBinaryTree
private

This is used if we are using the information gain and the binary numeric split.

Definition at line 232 of file hoeffding_tree_model.hpp.

Referenced by Serialize().

InfoHoeffdingTreeType* mlpack::tree::HoeffdingTreeModel::infoHoeffdingTree
private

This is used if we are using the information gain and the Hoeffding numeric split.

Definition at line 228 of file hoeffding_tree_model.hpp.

Referenced by Serialize().

TreeType mlpack::tree::HoeffdingTreeModel::type
private

The type of tree we are using.

Definition at line 216 of file hoeffding_tree_model.hpp.

Referenced by Serialize().


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