This class is a serializable Hoeffding tree model that can hold four different types of Hoeffding trees. More...
Public Types | |
typedef HoeffdingTree< GiniImpurity, BinaryDoubleNumericSplit, HoeffdingCategoricalSplit > | GiniBinaryTreeType |
Convenience typedef for GINI_BINARY tree type. More... | |
typedef HoeffdingTree< GiniImpurity, HoeffdingDoubleNumericSplit, HoeffdingCategoricalSplit > | GiniHoeffdingTreeType |
Convenience typedef for GINI_HOEFFDING tree type. More... | |
typedef HoeffdingTree< HoeffdingInformationGain, BinaryDoubleNumericSplit, HoeffdingCategoricalSplit > | InfoBinaryTreeType |
Convenience typedef for INFO_BINARY tree type. More... | |
typedef HoeffdingTree< HoeffdingInformationGain, HoeffdingDoubleNumericSplit, HoeffdingCategoricalSplit > | InfoHoeffdingTreeType |
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... | |
HoeffdingTreeModel & | operator= (const HoeffdingTreeModel &other) |
Copy the Hoeffding tree model from the given other model. More... | |
HoeffdingTreeModel & | operator= (HoeffdingTreeModel &&other) |
Move the Hoeffding tree model from the given other model. More... | |
template < typename Archive > | |
void | serialize (Archive &ar, const uint32_t) |
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... | |
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.
typedef HoeffdingTree<GiniImpurity, BinaryDoubleNumericSplit, HoeffdingCategoricalSplit> GiniBinaryTreeType |
Convenience typedef for GINI_BINARY tree type.
Definition at line 44 of file hoeffding_tree_model.hpp.
typedef HoeffdingTree<GiniImpurity, HoeffdingDoubleNumericSplit, HoeffdingCategoricalSplit> GiniHoeffdingTreeType |
Convenience typedef for GINI_HOEFFDING tree type.
Definition at line 41 of file hoeffding_tree_model.hpp.
typedef HoeffdingTree<HoeffdingInformationGain, BinaryDoubleNumericSplit, HoeffdingCategoricalSplit> InfoBinaryTreeType |
Convenience typedef for INFO_BINARY tree type.
Definition at line 50 of file hoeffding_tree_model.hpp.
typedef HoeffdingTree<HoeffdingInformationGain, HoeffdingDoubleNumericSplit, HoeffdingCategoricalSplit> InfoHoeffdingTreeType |
Convenience typedef for INFO_HOEFFDING tree type.
Definition at line 47 of file hoeffding_tree_model.hpp.
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.
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!
type | Type of tree that will be used. |
HoeffdingTreeModel | ( | const HoeffdingTreeModel & | other | ) |
Copy the Hoeffding tree model from the given other model.
other | Hoeffding tree model to copy. |
HoeffdingTreeModel | ( | HoeffdingTreeModel && | other | ) |
Move the Hoeffding tree model from the given other model.
other | Hoeffding tree model to move. |
~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.
This method just passes to the appropriate HoeffdingTree<...> constructor, and will train with one pass over the dataset.
dataset | Dataset to train on. |
datasetInfo | Information about dimensions of dataset. |
labels | Labels for training set. |
numClasses | Number of classes in dataset. |
batchTraining | Whether or not to train in batch. |
successProbability | Probability of success required in Hoeffding bound before a split can happen. |
maxSamples | Maximum number of samples before a split is forced. |
checkInterval | Number of samples required before each split check. |
minSamples | If the node has seen this many points or fewer, no split will be allowed. |
bins | Number of bins, for Hoeffding numeric split. |
observationsBeforeBinning | Number of observations before binning, for Hoeffding numeric split. |
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!
dataset | Dataset to classify. |
predictions | Vector to store predictions for test points in. |
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.
dataset | Dataset to classify. |
predictions | Vector to store predictions for test points in. |
probabilities | Vector to store probabilities for test points in. |
size_t NumNodes | ( | ) | const |
Get the number of nodes in the tree.
HoeffdingTreeModel& operator= | ( | const HoeffdingTreeModel & | other | ) |
Copy the Hoeffding tree model from the given other model.
other | Hoeffding tree model to copy. |
HoeffdingTreeModel& operator= | ( | HoeffdingTreeModel && | other | ) |
Move the Hoeffding tree model from the given other model.
other | Hoeffding tree model to move. |
|
inline |
Serialize the model.
Definition at line 169 of file hoeffding_tree_model.hpp.
References CEREAL_POINTER, HoeffdingTreeModel::GINI_BINARY, HoeffdingTreeModel::GINI_HOEFFDING, HoeffdingTreeModel::INFO_BINARY, and HoeffdingTreeModel::INFO_HOEFFDING.
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!
dataset | Dataset to train on. |
labels | Labels for training set. |
batchTraining | Whether or not to train in batch. |