mlpack
3.0.0
|
A density estimation tree is similar to both a decision tree and a space partitioning tree (like a kd-tree). More...
Public Types | |
typedef MatType::elem_type | ElemType |
The actual, underlying type we're working with. More... | |
typedef arma::Col< ElemType > | StatType |
The statistic type we are holding. More... | |
typedef MatType::vec_type | VecType |
The type of vector we are using. More... | |
Public Member Functions | |
DTree () | |
Create an empty density estimation tree. More... | |
DTree (const DTree &obj) | |
Create a tree that is the copy of the given tree. More... | |
DTree (DTree &&obj) | |
Create a tree by taking ownership of another tree (move constructor). More... | |
DTree (const StatType &maxVals, const StatType &minVals, const size_t totalPoints) | |
Create a density estimation tree with the given bounds and the given number of total points. More... | |
DTree (MatType &data) | |
Create a density estimation tree on the given data. More... | |
DTree (const StatType &maxVals, const StatType &minVals, const size_t start, const size_t end, const double logNegError) | |
Create a child node of a density estimation tree given the bounding box specified by maxVals and minVals, using the size given in start and end and the specified error. More... | |
DTree (const StatType &maxVals, const StatType &minVals, const size_t totalPoints, const size_t start, const size_t end) | |
Create a child node of a density estimation tree given the bounding box specified by maxVals and minVals, using the size given in start and end, and calculating the error with the total number of points given. More... | |
~DTree () | |
Clean up memory allocated by the tree. More... | |
double | AlphaUpper () const |
Return the upper part of the alpha sum. More... | |
TagType | BucketTag () const |
Return the current bucket's ID, if leaf, or -1 otherwise. More... | |
DTree & | Child (const size_t child) const |
Return the specified child (0 will be left, 1 will be right). More... | |
DTree *& | ChildPtr (const size_t child) |
double | ComputeValue (const VecType &query) const |
Compute the logarithm of the density estimate of a given query point. More... | |
void | ComputeVariableImportance (arma::vec &importances) const |
Compute the variable importance of each dimension in the learned tree. More... | |
size_t | End () const |
Return the first index of a point not contained in this node. More... | |
TagType | FindBucket (const VecType &query) const |
Return the tag of the leaf containing the query. More... | |
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. More... | |
DTree * | Left () const |
Return the left child. More... | |
double | LogNegativeError (const size_t totalPoints) const |
Compute the log-negative-error for this point, given the total number of points in the dataset. More... | |
double | LogNegError () const |
Return the log negative error of this node. More... | |
double | LogVolume () const |
Return the inverse of the volume of this node. More... | |
const StatType & | MaxVals () const |
Return the maximum values. More... | |
const StatType & | MinVals () const |
Return the minimum values. More... | |
size_t | NumChildren () const |
Return the number of children in this node. More... | |
DTree & | operator= (const DTree &obj) |
Copy the given tree. More... | |
DTree & | operator= (DTree &&obj) |
Take ownership of the given tree (move operator). More... | |
double | PruneAndUpdate (const double oldAlpha, const size_t points, const bool useVolReg=false) |
Perform alpha pruning on a tree. More... | |
double | Ratio () const |
Return the ratio of points in this node to the points in the whole dataset. More... | |
DTree * | Right () const |
Return the right child. More... | |
bool | Root () const |
Return whether or not this is the root of the tree. More... | |
template < typename Archive > | |
void | serialize (Archive &ar, const unsigned int) |
Serialize the density estimation tree. More... | |
size_t | SplitDim () const |
Return the split dimension of this node. More... | |
ElemType | SplitValue () const |
Return the split value of this node. More... | |
size_t | Start () const |
Return the starting index of points contained in this node. More... | |
size_t | SubtreeLeaves () const |
Return the number of leaves which are descendants of this node. More... | |
double | SubtreeLeavesLogNegError () const |
Return the log negative error of all descendants of this node. More... | |
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 tag (accessible with BucketTag()). More... | |
bool | WithinRange (const VecType &query) const |
Return whether a query point is within the range of this node. More... | |
Detailed Description
template<typenameMatType=arma::mat,typenameTagType=int>
class mlpack::det::DTree< MatType, TagType >
A density estimation tree is similar to both a decision tree and a space partitioning tree (like a kd-tree).
Each leaf represents a constant-density hyper-rectangle. The tree is constructed in such a way as to minimize the integrated square error between the probability distribution of the tree and the observed probability distribution of the data. Because the tree is similar to a decision tree, the density estimation tree can provide very fast density estimates for a given point.
For more information, see the following paper:
Member Typedef Documentation
◆ ElemType
typedef MatType::elem_type ElemType |
◆ StatType
◆ VecType
typedef MatType::vec_type VecType |
Constructor & Destructor Documentation
◆ DTree() [1/7]
DTree | ( | ) |
Create an empty density estimation tree.
◆ DTree() [2/7]
Create a tree that is the copy of the given tree.
- Parameters
-
obj Tree to copy.
◆ DTree() [3/7]
Create a tree by taking ownership of another tree (move constructor).
- Parameters
-
obj Tree to take ownership of.
◆ DTree() [4/7]
Create a density estimation tree with the given bounds and the given number of total points.
Children will not be created.
- Parameters
-
maxVals Maximum values of the bounding box. minVals Minimum values of the bounding box. totalPoints Total number of points in the dataset.
◆ DTree() [5/7]
DTree | ( | MatType & | data | ) |
Create a density estimation tree on the given data.
Children will be created following the procedure outlined in the paper. The data will be modified; it will be reordered similar to the way BinarySpaceTree modifies datasets.
- Parameters
-
data Dataset to build tree on.
◆ DTree() [6/7]
DTree | ( | const StatType & | maxVals, |
const StatType & | minVals, | ||
const size_t | start, | ||
const size_t | end, | ||
const double | logNegError | ||
) |
Create a child node of a density estimation tree given the bounding box specified by maxVals and minVals, using the size given in start and end and the specified error.
Children of this node will not be created recursively.
- Parameters
-
maxVals Upper bound of bounding box. minVals Lower bound of bounding box. start Start of points represented by this node in the data matrix. end End of points represented by this node in the data matrix. error log-negative error of this node.
◆ DTree() [7/7]
DTree | ( | const StatType & | maxVals, |
const StatType & | minVals, | ||
const size_t | totalPoints, | ||
const size_t | start, | ||
const size_t | end | ||
) |
Create a child node of a density estimation tree given the bounding box specified by maxVals and minVals, using the size given in start and end, and calculating the error with the total number of points given.
Children of this node will not be created recursively.
- Parameters
-
maxVals Upper bound of bounding box. minVals Lower bound of bounding box. start Start of points represented by this node in the data matrix. end End of points represented by this node in the data matrix.
◆ ~DTree()
~DTree | ( | ) |
Clean up memory allocated by the tree.
Member Function Documentation
◆ AlphaUpper()
|
inline |
◆ BucketTag()
|
inline |
◆ Child()
|
inline |
◆ ChildPtr()
◆ ComputeValue()
double ComputeValue | ( | const VecType & | query | ) | const |
Compute the logarithm of the density estimate of a given query point.
- Parameters
-
query Point to estimate density of.
◆ ComputeVariableImportance()
void ComputeVariableImportance | ( | arma::vec & | importances | ) | const |
Compute the variable importance of each dimension in the learned tree.
- Parameters
-
importances Vector to store the calculated importances in.
◆ End()
|
inline |
◆ FindBucket()
TagType FindBucket | ( | const VecType & | query | ) | const |
Return the tag of the leaf containing the query.
This is useful for generating class memberships.
- Parameters
-
query Query to search for.
◆ Grow()
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.
The points in the dataset will be reordered during tree growth.
- Parameters
-
data Dataset to build tree on. oldFromNew Mappings from old points to new points. useVolReg If true, volume regularization is used. maxLeafSize Maximum size of a leaf. minLeafSize Minimum size of a leaf.
◆ Left()
◆ LogNegativeError()
double LogNegativeError | ( | const size_t | totalPoints | ) | const |
Compute the log-negative-error for this point, given the total number of points in the dataset.
- Parameters
-
totalPoints Total number of points in the dataset.
◆ LogNegError()
|
inline |
◆ LogVolume()
|
inline |
◆ MaxVals()
|
inline |
◆ MinVals()
|
inline |
Return the minimum values.
Definition at line 326 of file dtree.hpp.
References DTree< MatType, TagType >::serialize().
◆ NumChildren()
|
inline |
◆ operator=() [1/2]
Copy the given tree.
- Parameters
-
obj Tree to copy.
◆ operator=() [2/2]
Take ownership of the given tree (move operator).
- Parameters
-
obj Tree to take ownership of.
◆ PruneAndUpdate()
double PruneAndUpdate | ( | const double | oldAlpha, |
const size_t | points, | ||
const bool | useVolReg = false |
||
) |
Perform alpha pruning on a tree.
Returns the new value of alpha.
- Parameters
-
oldAlpha Old value of alpha. points Total number of points in dataset. useVolReg If true, volume regularization is used.
- Returns
- New value of alpha.
◆ Ratio()
|
inline |
◆ Right()
◆ Root()
|
inline |
◆ serialize()
void serialize | ( | Archive & | ar, |
const unsigned | int | ||
) |
Serialize the density estimation tree.
Referenced by DTree< MatType, TagType >::MinVals().
◆ SplitDim()
|
inline |
◆ SplitValue()
|
inline |
◆ Start()
|
inline |
◆ SubtreeLeaves()
|
inline |
◆ SubtreeLeavesLogNegError()
|
inline |
◆ TagTree()
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 tag (accessible with BucketTag()).
This function calls itself recursively. The tag is incremented with operator++()
, so any TagType
overriding it will do.
- Parameters
-
tag Tag for the next leaf; leave at 0 for the initial call. everyNodde Whether to increment on every node, not just leaves.
◆ WithinRange()
bool WithinRange | ( | const VecType & | query | ) | const |
Return whether a query point is within the range of this node.
The documentation for this class was generated from the following file:
- src/mlpack/methods/det/dtree.hpp
Generated by
