15 #ifndef __MLPACK_METHODS_DET_DTREE_HPP 16 #define __MLPACK_METHODS_DET_DTREE_HPP 64 const size_t totalPoints);
74 DTree(arma::mat& data);
88 DTree(
const arma::vec& maxVals,
89 const arma::vec& minVals,
105 DTree(
const arma::vec& maxVals,
106 const arma::vec& minVals,
107 const size_t totalPoints,
124 double Grow(arma::mat& data,
125 arma::Col<size_t>& oldFromNew,
126 const bool useVolReg =
false,
127 const size_t maxLeafSize = 10,
128 const size_t minLeafSize = 5);
140 const bool useVolReg =
false);
156 void WriteTree(FILE *fp,
const size_t level = 0)
const;
165 int TagTree(
const int tag = 0);
291 template<
typename Archive>
301 ar &
CreateNVP(splitValue,
"splitValue");
302 ar &
CreateNVP(logNegError,
"logNegError");
303 ar &
CreateNVP(subtreeLeavesLogNegError,
"subtreeLeavesLogNegError");
304 ar &
CreateNVP(subtreeLeaves,
"subtreeLeaves");
309 ar &
CreateNVP(alphaUpper,
"alphaUpper");
311 if (Archive::is_loading::value)
335 const size_t minLeafSize = 5)
const;
341 const size_t splitDim,
342 const double splitValue,
343 arma::Col<size_t>& oldFromNew)
const;
350 #endif // __MLPACK_METHODS_DET_DTREE_HPP arma::vec & MaxVals()
Modify the maximum values.
DTree * Left() const
Return the left child.
double splitValue
The split value on the splitting dimension for this node.
double logNegError
log-negative-L2-error of the node.
~DTree()
Clean up memory allocated by the tree.
DTree * left
The left child.
Linear algebra utility functions, generally performed on matrices or vectors.
FirstShim< T > CreateNVP(T &t, const std::string &name, typename boost::enable_if< HasSerialize< T >>::type *=0)
Call this function to produce a name-value pair; this is similar to BOOST_SERIALIZATION_NVP(), but should be used for types that have a Serialize() function (or contain a type that has a Serialize() function) instead of a serialize() function.
double LogNegativeError(const size_t totalPoints) const
Compute the log-negative-error for this point, given the total number of points in the dataset...
arma::vec maxVals
Upper half of bounding box for this node.
bool FindSplit(const arma::mat &data, size_t &splitDim, double &splitValue, double &leftError, double &rightError, const size_t minLeafSize=5) const
Find the dimension to split on.
double LogNegError() const
Return the log negative error of this node.
size_t subtreeLeaves
Number of leaves of the subtree.
const arma::vec & MinVals() const
Return the minimum values.
const arma::vec & MaxVals() const
Return the maximum values.
double SplitValue() const
Return the split value of this node.
DTree * Right() const
Return the right child.
size_t start
The index of the first point in the dataset contained in this node (and its children).
arma::vec & MinVals()
Modify the minimum values.
size_t splitDim
The splitting dimension for this node.
size_t SubtreeLeaves() const
Return the number of leaves which are descendants of this node.
double AlphaUpper() const
Return the upper part of the alpha sum.
double PruneAndUpdate(const double oldAlpha, const size_t points, const bool useVolReg=false)
Perform alpha pruning on a tree.
bool WithinRange(const arma::vec &query) const
Return whether a query point is within the range of this node.
Include all of the base components required to write MLPACK methods, and the main MLPACK Doxygen docu...
size_t SplitData(arma::mat &data, const size_t splitDim, const double splitValue, arma::Col< size_t > &oldFromNew) const
Split the data, returning the number of points left of the split.
bool root
If true, this node is the root of the tree.
double ComputeValue(const arma::vec &query) const
Compute the logarithm of the density estimate of a given query point.
DTree * right
The right child.
size_t Start() const
Return the starting index of points contained in this node.
A density estimation tree is similar to both a decision tree and a space partitioning tree (like a kd...
double alphaUpper
Upper part of alpha sum; used for pruning.
double ratio
Ratio of the number of points in the node to the total number of points.
int bucketTag
The tag for the leaf, used for hashing points.
size_t SplitDim() const
Return the split dimension of this node.
void ComputeVariableImportance(arma::vec &importances) const
Compute the variable importance of each dimension in the learned tree.
double SubtreeLeavesLogNegError() const
Return the log negative error of all descendants of this node.
size_t End() const
Return the first index of a point not contained in this node.
double subtreeLeavesLogNegError
Sum of the error of the leaves of the subtree.
double logVolume
The logarithm of the volume of the node.
arma::vec minVals
Lower half of bounding box for this node.
void Serialize(Archive &ar, const unsigned int)
Serialize the density estimation tree.
bool Root() const
Return whether or not this is the root of the tree.
DTree()
Create an empty density estimation tree.
double Grow(arma::mat &data, arma::Col< size_t > &oldFromNew, const bool useVolReg=false, const size_t maxLeafSize=10, const size_t minLeafSize=5)
Greedily expand the tree.
int FindBucket(const arma::vec &query) const
Return the tag of the leaf containing the query.
void WriteTree(FILE *fp, const size_t level=0) const
Print the tree in a depth-first manner (this function is called recursively).
int TagTree(const int tag=0)
Index the buckets for possible usage later; this results in every leaf in the tree having a specific ...
size_t end
The index of the last point in the dataset contained in this node (and its children).
double LogVolume() const
Return the inverse of the volume of this node.
double Ratio() const
Return the ratio of points in this node to the points in the whole dataset.