#include <DecisionTree-inl.h>
Public Member Functions | |
NodePtr | apply (const Unary &op) const override |
apply unary operator. More... | |
NodePtr | apply (const UnaryAssignment &op, const Assignment< L > &assignment) const override |
Apply unary operator with assignment. More... | |
NodePtr | apply_f_op_g (const Node &g, const Binary &op) const override |
template<typename OP > | |
NodePtr | apply_fC_op_gL (const Leaf &gL, OP op) const |
NodePtr | apply_g_op_fC (const Choice &fC, const Binary &op) const override |
NodePtr | apply_g_op_fL (const Leaf &fL, const Binary &op) const override |
std::vector< NodePtr > & | branches () |
const std::vector< NodePtr > & | branches () const |
Choice () | |
Default constructor for serialization. More... | |
Choice (const Choice &f, const Choice &g, const Binary &op) | |
Construct from applying binary op to two Choice nodes. More... | |
Choice (const L &label, const Choice &f, const Unary &op) | |
Construct from applying unary op to a Choice node. More... | |
Choice (const L &label, const Choice &f, const UnaryAssignment &op, const Assignment< L > &assignment) | |
Constructor which accepts a UnaryAssignment op and the corresponding assignment. More... | |
Choice (const L &label, size_t count) | |
Constructor, given choice label and mandatory expected branch count. More... | |
NodePtr | choose (const L &label, size_t index) const override |
void | dot (std::ostream &os, const LabelFormatter &labelFormatter, const ValueFormatter &valueFormatter, bool showZero) const override |
bool | equals (const Node &q, const CompareFunc &compare) const override |
equality More... | |
bool | isLeaf () const override |
const L & | label () const |
Return the label of this choice node. More... | |
size_t | nrChoices () const |
const Y & | operator() (const Assignment< L > &x) const override |
evaluate More... | |
void | print (const std::string &s, const LabelFormatter &labelFormatter, const ValueFormatter &valueFormatter) const override |
print (as a tree). More... | |
void | push_back (NodePtr &&node) |
bool | sameLeaf (const Leaf &q) const override |
Choice-Leaf equality: always false. More... | |
bool | sameLeaf (const Node &q) const override |
polymorphic equality: if q is a leaf, could be... More... | |
~Choice () override | |
Public Member Functions inherited from gtsam::DecisionTree< L, Y >::Node | |
const void * | id () const |
Node () | |
virtual | ~Node () |
Static Public Member Functions | |
static NodePtr | Unique (const NodePtr &node) |
Merge branches with equal leaf values for every choice node in a decision tree. If all branches are the same (i.e. have the same leaf value), replace the choice node with the equivalent leaf node. More... | |
Public Attributes | |
std::vector< NodePtr > | branches_ |
L | label_ |
Private Types | |
using | Base = DecisionTree< L, Y >::Node |
using | ChoicePtr = std::shared_ptr< const Choice > |
Private Attributes | |
size_t | allSame_ |
Additional Inherited Members | |
Public Types inherited from gtsam::DecisionTree< L, Y >::Node | |
using | Ptr = std::shared_ptr< Node > |
Definition at line 162 of file DecisionTree-inl.h.
|
private |
Definition at line 472 of file DecisionTree-inl.h.
|
private |
Definition at line 176 of file DecisionTree-inl.h.
|
inline |
Default constructor for serialization.
Definition at line 180 of file DecisionTree-inl.h.
|
inlineoverride |
Definition at line 182 of file DecisionTree-inl.h.
|
inline |
Constructor, given choice label and mandatory expected branch count.
Definition at line 238 of file DecisionTree-inl.h.
|
inline |
Construct from applying binary op to two Choice nodes.
Definition at line 244 of file DecisionTree-inl.h.
|
inline |
Construct from applying unary op to a Choice node.
Definition at line 376 of file DecisionTree-inl.h.
|
inline |
Constructor which accepts a UnaryAssignment op and the corresponding assignment.
label | The label for this node. |
f | The original choice node to apply the op on. |
op | Function to apply on the choice node. Takes Assignment and value as arguments. |
assignment | The Assignment that will go to op. |
Definition at line 394 of file DecisionTree-inl.h.
|
inlineoverridevirtual |
apply unary operator.
Implements gtsam::DecisionTree< L, Y >::Node.
Definition at line 414 of file DecisionTree-inl.h.
|
inlineoverridevirtual |
Apply unary operator with assignment.
Implements gtsam::DecisionTree< L, Y >::Node.
Definition at line 420 of file DecisionTree-inl.h.
|
inlineoverridevirtual |
Implements gtsam::DecisionTree< L, Y >::Node.
Definition at line 431 of file DecisionTree-inl.h.
|
inline |
Definition at line 451 of file DecisionTree-inl.h.
|
inlineoverridevirtual |
Implements gtsam::DecisionTree< L, Y >::Node.
Definition at line 444 of file DecisionTree-inl.h.
|
inlineoverridevirtual |
Implements gtsam::DecisionTree< L, Y >::Node.
Definition at line 436 of file DecisionTree-inl.h.
|
inline |
Definition at line 290 of file DecisionTree-inl.h.
|
inline |
Definition at line 286 of file DecisionTree-inl.h.
|
inlineoverridevirtual |
choose a branch, recursively
Implements gtsam::DecisionTree< L, Y >::Node.
Definition at line 459 of file DecisionTree-inl.h.
|
inlineoverridevirtual |
output to graphviz (as a a graph)
Implements gtsam::DecisionTree< L, Y >::Node.
Definition at line 314 of file DecisionTree-inl.h.
|
inlineoverridevirtual |
equality
Implements gtsam::DecisionTree< L, Y >::Node.
Definition at line 348 of file DecisionTree-inl.h.
|
inlineoverridevirtual |
Implements gtsam::DecisionTree< L, Y >::Node.
Definition at line 235 of file DecisionTree-inl.h.
|
inline |
Return the label of this choice node.
Definition at line 278 of file DecisionTree-inl.h.
|
inline |
Definition at line 282 of file DecisionTree-inl.h.
|
inlineoverridevirtual |
evaluate
Implements gtsam::DecisionTree< L, Y >::Node.
Definition at line 361 of file DecisionTree-inl.h.
|
inlineoverridevirtual |
print (as a tree).
Implements gtsam::DecisionTree< L, Y >::Node.
Definition at line 304 of file DecisionTree-inl.h.
|
inline |
add a branch: TODO merge into constructor
Definition at line 295 of file DecisionTree-inl.h.
|
inlineoverridevirtual |
Choice-Leaf equality: always false.
Implements gtsam::DecisionTree< L, Y >::Node.
Definition at line 338 of file DecisionTree-inl.h.
|
inlineoverridevirtual |
polymorphic equality: if q is a leaf, could be...
Implements gtsam::DecisionTree< L, Y >::Node.
Definition at line 343 of file DecisionTree-inl.h.
|
inlinestatic |
Merge branches with equal leaf values for every choice node in a decision tree. If all branches are the same (i.e. have the same leaf value), replace the choice node with the equivalent leaf node.
This function applies the branch merging (if enabled) recursively on the decision tree represented by the root node passed in as the argument. It recurses to the leaf nodes and merges branches with equal leaf values in a bottom-up fashion.
Thus, if all branches of a choice node f
are the same, just return a single branch at each recursion step.
node | The root node of the decision tree. |
Definition at line 205 of file DecisionTree-inl.h.
|
private |
Incremental allSame. Records if all the branches are the same leaf.
Definition at line 174 of file DecisionTree-inl.h.
std::vector<NodePtr> gtsam::DecisionTree< L, Y >::Choice< L, Y >::branches_ |
The children of this Choice node.
Definition at line 167 of file DecisionTree-inl.h.
L gtsam::DecisionTree< L, Y >::Choice< L, Y >::label_ |
the label of the variable on which we split
Definition at line 164 of file DecisionTree-inl.h.