13 #ifndef MLPACK_METHODS_DET_DTREE_HPP
14 #define MLPACK_METHODS_DET_DTREE_HPP
44 template<
typename MatType = arma::mat,
45 typename TagType =
int>
52 typedef typename MatType::vec_type
VecType;
99 const size_t totalPoints);
109 DTree(MatType& data);
127 const double logNegError);
142 const size_t totalPoints,
159 double Grow(MatType& data,
160 arma::Col<size_t>& oldFromNew,
161 const bool useVolReg =
false,
162 const size_t maxLeafSize = 10,
163 const size_t minLeafSize = 5);
175 const bool useVolReg =
false);
193 TagType
TagTree(
const TagType& tag = 0,
bool everyNode =
false);
254 double subtreeLeavesLogNegError;
257 size_t subtreeLeaves;
281 size_t Start()
const {
return start; }
283 size_t End()
const {
return end; }
296 double Ratio()
const {
return ratio; }
304 bool Root()
const {
return root; }
318 DTree&
Child(
const size_t child)
const {
return !child ? *left : *right; }
331 template<
typename Archive>
332 void serialize(Archive& ar,
const unsigned int );
340 bool FindSplit(
const MatType& data,
345 const size_t minLeafSize = 5)
const;
350 size_t SplitData(MatType& data,
351 const size_t splitDim,
353 arma::Col<size_t>& oldFromNew)
const;
355 void FillMinMax(
const StatType& mins,
362 #include "dtree_impl.hpp"
364 #endif // MLPACK_METHODS_DET_DTREE_HPP
size_t Start() const
Return the starting index of points contained in this node.
DTree & operator=(const DTree &obj)
Copy the given tree.
size_t NumChildren() const
Return the number of children in this node.
double AlphaUpper() const
Return the upper part of the alpha sum.
double Grow(MatType &data, arma::Col< size_t > &oldFromNew, const bool useVolReg=false, const size_t maxLeafSize=10, const size_t minLeafSize=5)
Greedily expand the tree.
~DTree()
Clean up memory allocated by the tree.
MatType::elem_type ElemType
The actual, underlying type we're working with.
void serialize(Archive &ar, const unsigned int)
Serialize the density estimation tree.
arma::Col< ElemType > StatType
The statistic type we are holding.
DTree & Child(const size_t child) const
Return the specified child (0 will be left, 1 will be right).
double Ratio() const
Return the ratio of points in this node to the points in the whole dataset.
The core includes that mlpack expects; standard C++ includes and Armadillo.
double ComputeValue(const VecType &query) const
Compute the logarithm of the density estimate of a given query point.
size_t End() const
Return the first index of a point not contained in this node.
const StatType & MaxVals() const
Return the maximum values.
TagType FindBucket(const VecType &query) const
Return the tag of the leaf containing the query.
TagType TagTree(const TagType &tag=0, bool everyNode=false)
Index the buckets for possible usage later; this results in every leaf in the tree having a specific ...
bool Root() const
Return whether or not this is the root of the tree.
double SubtreeLeavesLogNegError() const
Return the log negative error of all descendants of this node.
size_t SplitDim() const
Return the split dimension of this node.
DTree * Right() const
Return the right child.
ElemType SplitValue() const
Return the split value of this node.
MatType::vec_type VecType
The type of vector we are using.
size_t SubtreeLeaves() const
Return the number of leaves which are descendants of this node.
double PruneAndUpdate(const double oldAlpha, const size_t points, const bool useVolReg=false)
Perform alpha pruning on a tree.
A density estimation tree is similar to both a decision tree and a space partitioning tree (like a kd...
double LogNegError() const
Return the log negative error of this node.
const StatType & MinVals() const
Return the minimum values.
void ComputeVariableImportance(arma::vec &importances) const
Compute the variable importance of each dimension in the learned tree.
double LogVolume() const
Return the inverse of the volume of this node.
TagType BucketTag() const
Return the current bucket's ID, if leaf, or -1 otherwise.
DTree * Left() const
Return the left child.
bool WithinRange(const VecType &query) const
Return whether a query point is within the range of this node.
double LogNegativeError(const size_t totalPoints) const
Compute the log-negative-error for this point, given the total number of points in the dataset...
DTree *& ChildPtr(const size_t child)
DTree()
Create an empty density estimation tree.