MLpp
ml::DecisionTrees::LeafNode< Y > Struct Template Reference

Terminal node, which returns a constant prediction value for features which ended up on it. More...

#include <DecisionTreeNodes.hpp>

Inheritance diagram for ml::DecisionTrees::LeafNode< Y >:
Collaboration diagram for ml::DecisionTrees::LeafNode< Y >:

Public Types

using arg_type = typename Node< Y >::arg_type
 
- Public Types inherited from ml::DecisionTrees::Node< Y >
typedef Eigen::Ref< const Eigen::VectorXd > arg_type
 

Public Member Functions

 LeafNode (double n_error, Y n_value, SplitNode< Y > *n_parent)
 Constructor. More...
 
operator() (arg_type) const override
 Returns a prediction given a feature vector. More...
 
unsigned int count_lower_nodes () const override
 Total number of nodes reachable from this one.
 
unsigned int count_leaf_nodes () const override
 Total number of leaf nodes reachable from this one, including itself.
 
double total_leaf_error () const override
 Total error of the training samples seen by the leaf nodes reachable from this node (including its own if leaf). More...
 
LeafNodeclone (SplitNode< Y > *cloned_parent) const override
 Make a perfect copy of the node. Function works recursively from root to leafs. More...
 
bool is_leaf () const override
 Return true if node is a leaf.
 
void collect_lowest_split_nodes (std::unordered_set< SplitNode< Y > * > &) override
 Adds all lowest split nodes. More...
 
- Public Member Functions inherited from ml::DecisionTrees::Node< Y >
 Node (double n_error, Y n_value, SplitNode< Y > *n_parent)
 Constructor. More...
 
virtual ~Node ()
 Virtual destructor.
 

Additional Inherited Members

- Public Attributes inherited from ml::DecisionTrees::Node< Y >
double error
 
value
 
SplitNode< Y > * parent
 

Detailed Description

template<class Y>
struct ml::DecisionTrees::LeafNode< Y >

Terminal node, which returns a constant prediction value for features which ended up on it.

Member Typedef Documentation

◆ arg_type

template<class Y >
using ml::DecisionTrees::LeafNode< Y >::arg_type = typename Node<Y>::arg_type

Type for feature vector.

Constructor & Destructor Documentation

◆ LeafNode()

template<class Y >
ml::DecisionTrees::LeafNode< Y >::LeafNode ( double  n_error,
n_value,
SplitNode< Y > *  n_parent 
)
inline

Constructor.

Parameters
n_errorPrediction error value on training data which reached this node.
n_valuePrediction value assigned to this node.
n_parentLink to parent node.
Exceptions
std::domain_errorIf n_error < 0.

Member Function Documentation

◆ operator()()

template<class Y >
Y ml::DecisionTrees::LeafNode< Y >::operator() ( arg_type  x) const
inlineoverridevirtual

Returns a prediction given a feature vector.

Parameters
xFeature vector.
Returns
Prediction value.

Implements ml::DecisionTrees::Node< Y >.

◆ total_leaf_error()

template<class Y >
double ml::DecisionTrees::LeafNode< Y >::total_leaf_error ( ) const
inlineoverridevirtual

Total error of the training samples seen by the leaf nodes reachable from this node (including its own if leaf).

Has the invariant total_leaf_error() <= error.

Implements ml::DecisionTrees::Node< Y >.

◆ clone()

template<class Y >
LeafNode* ml::DecisionTrees::LeafNode< Y >::clone ( SplitNode< Y > *  cloned_parent) const
inlineoverridevirtual

Make a perfect copy of the node. Function works recursively from root to leafs.

Parameters
[in]cloned_parentPointer to already cloned parent.

Implements ml::DecisionTrees::Node< Y >.

◆ collect_lowest_split_nodes()

template<class Y >
void ml::DecisionTrees::LeafNode< Y >::collect_lowest_split_nodes ( std::unordered_set< SplitNode< Y > * > &  s)
inlineoverridevirtual

Adds all lowest split nodes.

Walks over this node and all below it, adding to s every split node which has only leaf nodes as children.

Parameters
[out]sSet of pointers to split nodes.

Implements ml::DecisionTrees::Node< Y >.


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