13 #ifndef MLPACK_METHODS_HOEFFDING_TREES_HOEFFDING_TREE_HPP
14 #define MLPACK_METHODS_HOEFFDING_TREES_HOEFFDING_TREE_HPP
55 template<
typename FitnessFunction = GiniImpurity,
56 template<
typename>
class NumericSplitType =
58 template<
typename>
class CategoricalSplitType =
59 HoeffdingCategoricalSplit
91 template<
typename MatType>
94 const arma::Row<size_t>& labels,
95 const size_t numClasses,
96 const bool batchTraining =
true,
97 const double successProbability = 0.95,
98 const size_t maxSamples = 0,
99 const size_t checkInterval = 100,
100 const size_t minSamples = 100,
101 const CategoricalSplitType<FitnessFunction>& categoricalSplitIn
102 = CategoricalSplitType<FitnessFunction>(0, 0),
103 const NumericSplitType<FitnessFunction>& numericSplitIn =
104 NumericSplitType<FitnessFunction>(0));
128 const size_t numClasses,
129 const double successProbability = 0.95,
130 const size_t maxSamples = 0,
131 const size_t checkInterval = 100,
132 const size_t minSamples = 100,
133 const CategoricalSplitType<FitnessFunction>& categoricalSplitIn
134 = CategoricalSplitType<FitnessFunction>(0, 0),
135 const NumericSplitType<FitnessFunction>& numericSplitIn =
136 NumericSplitType<FitnessFunction>(0),
137 std::unordered_map<
size_t, std::pair<size_t, size_t>>*
138 dimensionMappings = NULL,
139 const bool copyDatasetInfo =
true);
168 template<
typename MatType>
169 void Train(
const MatType& data,
170 const arma::Row<size_t>& labels,
171 const bool batchTraining =
true);
177 template<
typename MatType>
178 void Train(
const MatType& data,
180 const arma::Row<size_t>& labels,
181 const bool batchTraining =
true);
189 template<
typename VecType>
190 void Train(
const VecType& point,
const size_t label);
247 template<
typename VecType>
257 template<
typename VecType>
258 size_t Classify(
const VecType& point)
const;
274 template<
typename VecType>
275 void Classify(
const VecType& point,
size_t& prediction,
double& probability)
285 template<
typename MatType>
286 void Classify(
const MatType& data, arma::Row<size_t>& predictions)
const;
299 template<
typename MatType>
301 arma::Row<size_t>& predictions,
302 arma::rowvec& probabilities)
const;
310 template<
typename Archive>
311 void serialize(Archive& ar,
const unsigned int );
317 std::vector<NumericSplitType<FitnessFunction>> numericSplits;
319 std::vector<CategoricalSplitType<FitnessFunction>> categoricalSplits;
322 std::unordered_map<size_t, std::pair<size_t, size_t>>* dimensionMappings;
333 size_t checkInterval;
341 double successProbability;
346 size_t splitDimension;
348 size_t majorityClass;
351 double majorityProbability;
353 typename CategoricalSplitType<FitnessFunction>::SplitInfo categoricalSplit;
355 typename NumericSplitType<FitnessFunction>::SplitInfo numericSplit;
357 std::vector<HoeffdingTree*> children;
363 #include "hoeffding_tree_impl.hpp"
HoeffdingTree()
Construct a Hoeffding tree with no data and no information.
Auxiliary information for a dataset, including mappings to/from strings (or other types) and the data...
double SuccessProbability() const
Get the confidence required for a split.
size_t SplitDimension() const
Get the splitting dimension (size_t(-1) if no split).
size_t CheckInterval() const
Get the number of samples before a split check is performed.
~HoeffdingTree()
Clean up memory.
The HoeffdingTree object represents all of the necessary information for a Hoeffding-bound-based deci...
The core includes that mlpack expects; standard C++ includes and Armadillo.
void serialize(Archive &ar, const unsigned int)
Serialize the split.
void Train(const MatType &data, const arma::Row< size_t > &labels, const bool batchTraining=true)
Train on a set of points, either in streaming mode or in batch mode, with the given labels...
const HoeffdingTree & Child(const size_t i) const
Get a child.
void CreateChildren()
Given that this node should split, create the children.
CategoricalSplitType< FitnessFunction > CategoricalSplit
Allow access to the categorical split type.
size_t MajorityClass() const
Get the majority class.
size_t CalculateDirection(const VecType &point) const
Given a point and that this node is not a leaf, calculate the index of the child node this point woul...
size_t NumChildren() const
Get the number of children.
HoeffdingNumericSplit< FitnessFunction, double > HoeffdingDoubleNumericSplit
Convenience typedef.
size_t & MajorityClass()
Modify the majority class.
size_t SplitCheck()
Check if a split would satisfy the conditions of the Hoeffding bound with the node's specified succes...
HoeffdingTree & Child(const size_t i)
Modify a child.
size_t MaxSamples() const
Get the maximum number of samples before a split is forced.
size_t NumDescendants() const
Get the size of the Hoeffding Tree.
size_t MinSamples() const
Get the minimum number of samples for a split.
double MajorityProbability() const
Get the probability of the majority class (based on training samples).
NumericSplitType< FitnessFunction > NumericSplit
Allow access to the numeric split type.
double & MajorityProbability()
Modify the probability of the majority class.
size_t Classify(const VecType &point) const
Classify the given point, using this node and the entire (sub)tree beneath it.