curfil  ..
 All Classes Functions Variables Typedefs Friends Groups Pages
Public Member Functions | List of all members
curfil::RandomTree< Instance, FeatureFunction > Class Template Reference

A sub-tree with histograms and pointers to the parent and children. More...

#include <random_tree.h>

Public Member Functions

 RandomTree (const size_t &nodeId, const int level, const std::vector< const Instance * > &samples, size_t numClasses, const boost::shared_ptr< RandomTree< Instance, FeatureFunction > > &parent=boost::shared_ptr< RandomTree< Instance, FeatureFunction > >())
 create a sub-tree at the given level and nodeId using samples provided
 RandomTree (const size_t &nodeId, const int level, const boost::shared_ptr< RandomTree< Instance, FeatureFunction > > &parent, const std::vector< WeightType > &histogram)
 create a sub-tree at the given level and nodeId using the histogram provided
bool hasPureHistogram () const
 returns true iff the entropy is zero
size_t getNumClasses () const
void collectNodeIndices (const Instance &instance, std::set< unsigned int > &nodeSet, bool includeRoot) const
 For a given instance, collect the set of all nodes this sample traverses through.
void collectLeafNodes (std::vector< size_t > &leafSet)
 collect all leaf nodes
LabelType classify (const Instance &instance) const
 Classify an instance by traversing the tree and returning the tree leaf nodes leaf class.
const cuv::ndarray< double,
cuv::host_memory_space > & 
classifySoft (const Instance &instance) const
size_t getNumTrainSamples () const
const std::map< std::string,
double > & 
getTimerValues () const
const std::map< std::string,
std::string > & 
getTimerAnnotations () const
void setTimerValue (const std::string &key, utils::Timer &timer)
 set the timer value used when profiling
template<class V >
void setTimerAnnotation (const std::string &key, const V &annotation)
 set the timer annotation
void addTimerValue (const std::string &key, utils::Timer &timer)
 add the given timer seconds
void setTimerValue (const std::string &key, const double timeInSeconds)
 set a timer to the given seconds
void addTimerValue (const std::string &key, const double timeInSeconds)
 add the given seconds to the timer
boost::shared_ptr< const
RandomTree< Instance,
FeatureFunction > > 
getLeft () const
boost::shared_ptr< const
RandomTree< Instance,
FeatureFunction > > 
getRight () const
int getLevel () const
bool isRoot () const
const RandomTree< Instance,
FeatureFunction > * 
getRoot () const
void countFeatures (std::map< std::string, size_t > &featureCounts) const
size_t countNodes () const
size_t countLeafNodes () const
size_t getTreeDepth () const
void addChildren (const SplitFunction< Instance, FeatureFunction > &split, boost::shared_ptr< RandomTree< Instance, FeatureFunction > > left, boost::shared_ptr< RandomTree< Instance, FeatureFunction > > right)
 Links the given left/right subtrees as children to this one.
bool isLeaf () const
const SplitFunction< Instance,
FeatureFunction > & 
getSplit () const
size_t getNodeId () const
size_t getTreeId () const
void normalizeHistograms (const cuv::ndarray< WeightType, cuv::host_memory_space > &priorDistribution, const double histogramBias)
 normalize the histograms of the tree and its branches
const cuv::ndarray< WeightType,
cuv::host_memory_space > & 
getHistogram () const
const cuv::ndarray< double,
cuv::host_memory_space > & 
getNormalizedHistogram () const
const std::vector< Instance > & getTrainSamples () const
void setAllPixelsHistogram (size_t label, double value)
 add the passed value to the label histogram count
const RandomTree< Instance,
FeatureFunction > * 
setAllPixelsHistogram (const Instance &instance)
 traverses the tree to the leaf then increments the instance label's histogram
void updateHistograms ()
 copies the values of allPixelsHistgrams into histograms
void recomputeHistogramNoFlipping (const std::vector< const Instance * > &samples)
 recomputes the correct histograms, they were changed when checking for flipped features

Detailed Description

template<class Instance, class FeatureFunction>
class curfil::RandomTree< Instance, FeatureFunction >

A sub-tree with histograms and pointers to the parent and children.

Definition at line 472 of file random_tree.h.

Member Function Documentation

template<class Instance, class FeatureFunction>
void curfil::RandomTree< Instance, FeatureFunction >::addChildren ( const SplitFunction< Instance, FeatureFunction > &  split,
boost::shared_ptr< RandomTree< Instance, FeatureFunction > >  left,
boost::shared_ptr< RandomTree< Instance, FeatureFunction > >  right 
)
inline

Links the given left/right subtrees as children to this one.

Assigns unique labels to the children nodes. Makes the current node a non-leaf node. This tree node assumes ownership of split and both children.

Definition at line 735 of file random_tree.h.

template<class Instance, class FeatureFunction>
const cuv::ndarray<double, cuv::host_memory_space>& curfil::RandomTree< Instance, FeatureFunction >::classifySoft ( const Instance &  instance) const
inline
Returns
the histogram of the leaf reached when classifying the instance

Definition at line 592 of file random_tree.h.

template<class Instance, class FeatureFunction>
void curfil::RandomTree< Instance, FeatureFunction >::countFeatures ( std::map< std::string, size_t > &  featureCounts) const
inline
Returns
the number of features grouped by their type

Definition at line 694 of file random_tree.h.

template<class Instance, class FeatureFunction>
size_t curfil::RandomTree< Instance, FeatureFunction >::countLeafNodes ( ) const
inline
Returns
number of leaf nodes

Definition at line 715 of file random_tree.h.

template<class Instance, class FeatureFunction>
size_t curfil::RandomTree< Instance, FeatureFunction >::countNodes ( ) const
inline
Returns
the number of nodes

Definition at line 708 of file random_tree.h.

template<class Instance, class FeatureFunction>
const cuv::ndarray<WeightType, cuv::host_memory_space>& curfil::RandomTree< Instance, FeatureFunction >::getHistogram ( ) const
inline
Returns
the histogram associated with the node

Definition at line 824 of file random_tree.h.

template<class Instance, class FeatureFunction>
boost::shared_ptr<const RandomTree<Instance, FeatureFunction> > curfil::RandomTree< Instance, FeatureFunction >::getLeft ( ) const
inline
Returns
the left branch of the tree

Definition at line 656 of file random_tree.h.

template<class Instance, class FeatureFunction>
int curfil::RandomTree< Instance, FeatureFunction >::getLevel ( ) const
inline
Returns
the current level

Definition at line 670 of file random_tree.h.

template<class Instance, class FeatureFunction>
size_t curfil::RandomTree< Instance, FeatureFunction >::getNodeId ( ) const
inline
Returns
the current node Id

Definition at line 778 of file random_tree.h.

template<class Instance, class FeatureFunction>
const cuv::ndarray<double, cuv::host_memory_space>& curfil::RandomTree< Instance, FeatureFunction >::getNormalizedHistogram ( ) const
inline
Returns
the normalized histogram associated with the node

Definition at line 831 of file random_tree.h.

template<class Instance, class FeatureFunction>
size_t curfil::RandomTree< Instance, FeatureFunction >::getNumClasses ( ) const
inline
Returns
the number of labels

Definition at line 540 of file random_tree.h.

template<class Instance, class FeatureFunction>
size_t curfil::RandomTree< Instance, FeatureFunction >::getNumTrainSamples ( ) const
inline
Returns
number of samples

Definition at line 599 of file random_tree.h.

template<class Instance, class FeatureFunction>
boost::shared_ptr<const RandomTree<Instance, FeatureFunction> > curfil::RandomTree< Instance, FeatureFunction >::getRight ( ) const
inline
Returns
the right branch of the treeunit_testing

Definition at line 663 of file random_tree.h.

template<class Instance, class FeatureFunction>
const RandomTree<Instance, FeatureFunction>* curfil::RandomTree< Instance, FeatureFunction >::getRoot ( ) const
inline
Returns
the root of the tree

Definition at line 684 of file random_tree.h.

template<class Instance, class FeatureFunction>
const SplitFunction<Instance, FeatureFunction>& curfil::RandomTree< Instance, FeatureFunction >::getSplit ( ) const
inline
Returns
the split associated with the subtree

Definition at line 771 of file random_tree.h.

template<class Instance, class FeatureFunction>
const std::map<std::string, std::string>& curfil::RandomTree< Instance, FeatureFunction >::getTimerAnnotations ( ) const
inline
Returns
the timers annotations

Definition at line 613 of file random_tree.h.

template<class Instance, class FeatureFunction>
const std::map<std::string, double>& curfil::RandomTree< Instance, FeatureFunction >::getTimerValues ( ) const
inline
Returns
the timers for the subtree

Definition at line 606 of file random_tree.h.

template<class Instance, class FeatureFunction>
const std::vector<Instance>& curfil::RandomTree< Instance, FeatureFunction >::getTrainSamples ( ) const
inline
Returns
the train samples for the current node

Definition at line 844 of file random_tree.h.

template<class Instance, class FeatureFunction>
size_t curfil::RandomTree< Instance, FeatureFunction >::getTreeDepth ( ) const
inline
Returns
depth of the tree

Definition at line 722 of file random_tree.h.

template<class Instance, class FeatureFunction>
size_t curfil::RandomTree< Instance, FeatureFunction >::getTreeId ( ) const
inline
Returns
the tree Id

Definition at line 785 of file random_tree.h.

template<class Instance, class FeatureFunction>
bool curfil::RandomTree< Instance, FeatureFunction >::isLeaf ( ) const
inline
Returns
whether this is a leaf node

Definition at line 764 of file random_tree.h.

template<class Instance, class FeatureFunction>
bool curfil::RandomTree< Instance, FeatureFunction >::isRoot ( ) const
inline
Returns
whether this is the root node

Definition at line 677 of file random_tree.h.


The documentation for this class was generated from the following file: