13 #ifndef MLPACK_METHODS_DET_DTREE_HPP
14 #define MLPACK_METHODS_DET_DTREE_HPP
60 DTree(
const arma::vec& maxVals,
61 const arma::vec& minVals,
62 const size_t totalPoints);
72 DTree(arma::mat& data);
86 DTree(
const arma::vec& maxVals,
87 const arma::vec& minVals,
90 const double logNegError);
103 DTree(
const arma::vec& maxVals,
104 const arma::vec& minVals,
105 const size_t totalPoints,
122 double Grow(arma::mat& data,
123 arma::Col<size_t>& oldFromNew,
124 const bool useVolReg =
false,
125 const size_t maxLeafSize = 10,
126 const size_t minLeafSize = 5);
138 const bool useVolReg =
false);
154 void WriteTree(FILE *fp,
const size_t level = 0)
const;
163 int TagTree(
const int tag = 0);
222 double subtreeLeavesLogNegError;
225 size_t subtreeLeaves;
249 size_t Start()
const {
return start; }
251 size_t End()
const {
return end; }
264 double Ratio()
const {
return ratio; }
272 bool Root()
const {
return root; }
277 const arma::vec&
MaxVals()
const {
return maxVals; }
282 const arma::vec&
MinVals()
const {
return minVals; }
289 template<
typename Archive>
299 ar &
CreateNVP(splitValue,
"splitValue");
300 ar &
CreateNVP(logNegError,
"logNegError");
301 ar &
CreateNVP(subtreeLeavesLogNegError,
"subtreeLeavesLogNegError");
302 ar &
CreateNVP(subtreeLeaves,
"subtreeLeaves");
307 ar &
CreateNVP(alphaUpper,
"alphaUpper");
309 if (Archive::is_loading::value)
328 bool FindSplit(
const arma::mat& data,
333 const size_t minLeafSize = 5)
const;
338 size_t SplitData(arma::mat& data,
339 const size_t splitDim,
340 const double splitValue,
341 arma::Col<size_t>& oldFromNew)
const;
348 #endif // MLPACK_METHODS_DET_DTREE_HPP
double SplitValue() const
Return the split value of this node.
size_t Start() const
Return the starting index of points contained in this node.
double AlphaUpper() const
Return the upper part of the alpha sum.
~DTree()
Clean up memory allocated by the tree.
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 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.
arma::vec & MaxVals()
Modify the maximum values.
const arma::vec & MinVals() const
Return the minimum values.
size_t End() const
Return the first index of a point not contained in this node.
void Serialize(Archive &ar, const unsigned int)
Serialize the density estimation tree.
void WriteTree(FILE *fp, const size_t level=0) const
Print the tree in a depth-first manner (this function is called recursively).
bool WithinRange(const arma::vec &query) const
Return whether a query point is within the range of this node.
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.
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.
int TagTree(const int tag=0)
Index the buckets for possible usage later; this results in every leaf in the tree having a specific ...
double ComputeValue(const arma::vec &query) const
Compute the logarithm of the density estimate of a given query point.
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.
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.
DTree * Left() const
Return the left child.
const arma::vec & MaxVals() const
Return the maximum values.
double LogNegativeError(const size_t totalPoints) const
Compute the log-negative-error for this point, given the total number of points in the dataset...
int FindBucket(const arma::vec &query) const
Return the tag of the leaf containing the query.
arma::vec & MinVals()
Modify the minimum values.
DTree()
Create an empty density estimation tree.