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 size_t SubtreeLeaves() const
Return the number of leaves which are descendants of this node.
void WriteTree(FILE *fp, const size_t level=0) const
Print the tree in a depth-first manner (this function is called recursively).
size_t SplitDim() const
Return the split dimension of this node.
~DTree()
Clean up memory allocated by the tree.
size_t Start() const
Return the starting index of points contained in this node.
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.
const arma::vec & MinVals() const
Return the minimum values.
double LogNegError() const
Return the log negative error of this node.
The core includes that mlpack expects; standard C++ includes and Armadillo.
arma::vec & MaxVals()
Modify the maximum values.
double Ratio() const
Return the ratio of points in this node to the points in the whole dataset.
DTree * Left() const
Return the left child.
void Serialize(Archive &ar, const unsigned int)
Serialize the density estimation tree.
size_t End() const
Return the first index of a point not contained in this node.
bool WithinRange(const arma::vec &query) const
Return whether a query point is within the range of this node.
int FindBucket(const arma::vec &query) const
Return the tag of the leaf containing the query.
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.
DTree * Right() const
Return the right child.
double LogVolume() const
Return the inverse of the volume of this node.
double SubtreeLeavesLogNegError() const
Return the log negative error of all descendants of this node.
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 PruneAndUpdate(const double oldAlpha, const size_t points, const bool useVolReg=false)
Perform alpha pruning on a tree.
void ComputeVariableImportance(arma::vec &importances) const
Compute the variable importance of each dimension in the learned tree.
A density estimation tree is similar to both a decision tree and a space partitioning tree (like a kd...
double LogNegativeError(const size_t totalPoints) const
Compute the log-negative-error for this point, given the total number of points in the dataset...
double ComputeValue(const arma::vec &query) const
Compute the logarithm of the density estimate of a given query point.
double AlphaUpper() const
Return the upper part of the alpha sum.
double SplitValue() const
Return the split value of this node.
const arma::vec & MaxVals() const
Return the maximum values.
arma::vec & MinVals()
Modify the minimum values.
bool Root() const
Return whether or not this is the root of the tree.
DTree()
Create an empty density estimation tree.