#include <DecisionTreeFactor.h>

Public Types | |
| typedef AlgebraicDecisionTree< Key > | ADT |
| typedef DiscreteFactor | Base |
| Typedef to base class. More... | |
| using | Binary = std::function< double(const double, const double)> |
| typedef std::shared_ptr< DecisionTreeFactor > | shared_ptr |
| typedef DecisionTreeFactor | This |
| using | Unary = std::function< double(const double &)> |
| using | UnaryAssignment = std::function< double(const Assignment< Key > &, const double &)> |
Public Types inherited from gtsam::DiscreteFactor | |
| typedef Factor | Base |
| Our base class. More... | |
| using | Binary = std::function< double(const double, const double)> |
| typedef std::shared_ptr< DiscreteFactor > | shared_ptr |
| shared_ptr to this class More... | |
| typedef DiscreteFactor | This |
| This class. More... | |
| using | Unary = std::function< double(const double &)> |
| using | UnaryAssignment = std::function< double(const Assignment< Key > &, const double &)> |
| using | Values = DiscreteValues |
| backwards compatibility More... | |
| using | Names = DiscreteValues::Names |
| Translation table from values to strings. More... | |
Public Types inherited from gtsam::Factor | |
| typedef KeyVector::const_iterator | const_iterator |
| Const iterator over keys. More... | |
| typedef KeyVector::iterator | iterator |
| Iterator over keys. More... | |
Public Types inherited from gtsam::AlgebraicDecisionTree< Key > | |
| using | Base = DecisionTree< Key, double > |
Public Types inherited from gtsam::DecisionTree< Key, double > | |
| using | Binary = std::function< double(const double &, const double &)> |
| using | CompareFunc = std::function< bool(const double &, const double &)> |
| using | LabelC = std::pair< Key, size_t > |
| using | LabelFormatter = std::function< std::string(Key)> |
| using | NodePtr = typename Node::Ptr |
| using | Unary = std::function< double(const double &)> |
| using | UnaryAssignment = std::function< double(const Assignment< Key > &, const double &)> |
| using | ValueFormatter = std::function< std::string(double)> |
Public Member Functions | |
Standard Constructors | |
| DecisionTreeFactor () | |
| DecisionTreeFactor (const DiscreteKeys &keys, const ADT &potentials) | |
| DecisionTreeFactor (const DiscreteKeys &keys, const std::vector< double > &table) | |
| Constructor from doubles. More... | |
| DecisionTreeFactor (const DiscreteKeys &keys, const std::string &table) | |
| Constructor from string. More... | |
| template<class SOURCE > | |
| DecisionTreeFactor (const DiscreteKey &key, SOURCE table) | |
| Single-key specialization. More... | |
| DecisionTreeFactor (const DiscreteKey &key, const std::vector< double > &row) | |
| Single-key specialization, with vector of doubles. More... | |
| DecisionTreeFactor (const DiscreteConditional &c) | |
Testable | |
| bool | equals (const DiscreteFactor &other, double tol=1e-9) const override |
| equality More... | |
| void | print (const std::string &s="DecisionTreeFactor:\n", const KeyFormatter &formatter=DefaultKeyFormatter) const override |
| print More... | |
Advanced Interface | |
| DecisionTreeFactor | apply (Unary op) const |
| DecisionTreeFactor | apply (UnaryAssignment op) const |
| DecisionTreeFactor | apply (const DecisionTreeFactor &f, Binary op) const |
| shared_ptr | combine (size_t nrFrontals, Binary op) const |
| shared_ptr | combine (const Ordering &keys, Binary op) const |
| std::vector< std::pair< DiscreteValues, double > > | enumerate () const |
| Enumerate all values into a map from values to double. More... | |
| std::vector< double > | probabilities () const |
| Get all the probabilities in order of assignment values. More... | |
| double | computeThreshold (const size_t N) const |
Compute the probability value which is the threshold above which only N leaves are present. More... | |
| DecisionTreeFactor | prune (size_t maxNrAssignments) const |
| Prune the decision tree of discrete variables. More... | |
| uint64_t | nrValues () const override |
Wrapper support | |
| void | dot (std::ostream &os, const KeyFormatter &keyFormatter=DefaultKeyFormatter, bool showZero=true) const |
| void | dot (const std::string &name, const KeyFormatter &keyFormatter=DefaultKeyFormatter, bool showZero=true) const |
| std::string | dot (const KeyFormatter &keyFormatter=DefaultKeyFormatter, bool showZero=true) const |
| std::string | markdown (const KeyFormatter &keyFormatter=DefaultKeyFormatter, const Names &names={}) const override |
| Render as markdown table. More... | |
| std::string | html (const KeyFormatter &keyFormatter=DefaultKeyFormatter, const Names &names={}) const override |
| Render as html table. More... | |
HybridValues methods. | |
| double | error (const HybridValues &values) const override |
Public Member Functions inherited from gtsam::DiscreteFactor | |
| DiscreteFactor () | |
| template<typename CONTAINER > | |
| DiscreteFactor (const CONTAINER &keys, const std::map< Key, size_t > cardinalities={}) | |
| void | print (const std::string &s="DiscreteFactor\n", const KeyFormatter &formatter=DefaultKeyFormatter) const override |
| print More... | |
| DiscreteKeys | discreteKeys () const |
| Return all the discrete keys associated with this factor. More... | |
| std::map< Key, size_t > | cardinalities () const |
| size_t | cardinality (Key j) const |
| double | operator() (const DiscreteValues &values) const |
| Find value for given assignment of values to variables. More... | |
| double | error (const HybridValues &c) const override |
| virtual AlgebraicDecisionTree< Key > | errorTree () const |
| Compute error for each assignment and return as a tree. More... | |
| DiscreteFactor::shared_ptr | scale () const |
| Scale the factor values by the maximum to prevent underflow/overflow. More... | |
Public Member Functions inherited from gtsam::Factor | |
| virtual | ~Factor ()=default |
| Default destructor. More... | |
| bool | empty () const |
| Whether the factor is empty (involves zero variables). More... | |
| Key | front () const |
| First key. More... | |
| Key | back () const |
| Last key. More... | |
| const_iterator | find (Key key) const |
| find More... | |
| const KeyVector & | keys () const |
| Access the factor's involved variable keys. More... | |
| const_iterator | begin () const |
| const_iterator | end () const |
| size_t | size () const |
| virtual void | printKeys (const std::string &s="Factor", const KeyFormatter &formatter=DefaultKeyFormatter) const |
| print only keys More... | |
| bool | equals (const This &other, double tol=1e-9) const |
| check equality More... | |
| KeyVector & | keys () |
| iterator | begin () |
| iterator | end () |
Public Member Functions inherited from gtsam::AlgebraicDecisionTree< Key > | |
| AlgebraicDecisionTree (const AlgebraicDecisionTree< M > &other, const std::map< M, Key > &map) | |
| AlgebraicDecisionTree (const Base &add) | |
| AlgebraicDecisionTree (const DecisionTree< Key, X > &other, Func f) | |
Create from an arbitrary DecisionTree<L, X> by operating on it with a functional f. More... | |
| AlgebraicDecisionTree (const Key &label, double y1, double y2) | |
| AlgebraicDecisionTree (const std::vector< typename Base::LabelC > &labelCs, const std::string &table) | |
| Create from keys and string table. More... | |
| AlgebraicDecisionTree (const std::vector< typename Base::LabelC > &labelCs, const std::vector< double > &ys) | |
| Create from keys with cardinalities and a vector table. More... | |
| AlgebraicDecisionTree (const typename Base::LabelC &labelC, double y1, double y2) | |
| Create a new leaf function splitting on a variable. More... | |
| AlgebraicDecisionTree (const typename Base::NodePtr root) | |
| Constructor which accepts root pointer. More... | |
| AlgebraicDecisionTree (double leaf=1.0) | |
| AlgebraicDecisionTree (Iterator begin, Iterator end, const Key &label) | |
| Create a range of decision trees, splitting on a single variable. More... | |
| bool | equals (const AlgebraicDecisionTree &other, double tol=1e-9) const |
Equality method customized to value type double. More... | |
| double | max () const |
| Find the maximum values amongst all leaves. More... | |
| double | min () const |
| Find the minimum values amongst all leaves. More... | |
| AlgebraicDecisionTree | normalize () const |
| Helper method to perform normalization such that all leaves in the tree sum to 1. More... | |
| AlgebraicDecisionTree | operator* (const AlgebraicDecisionTree &g) const |
| AlgebraicDecisionTree | operator+ (const AlgebraicDecisionTree &g) const |
| AlgebraicDecisionTree | operator- () const |
| AlgebraicDecisionTree | operator- (const AlgebraicDecisionTree &g) const |
| AlgebraicDecisionTree | operator/ (const AlgebraicDecisionTree &g) const |
| void | print (const std::string &s="", const typename Base::LabelFormatter &labelFormatter=&DefaultFormatter) const |
print method customized to value type double. More... | |
| double | sum () const |
| Compute sum of all values. More... | |
| AlgebraicDecisionTree | sum (const Key &label, size_t cardinality) const |
| AlgebraicDecisionTree | sum (const typename Base::LabelC &labelC) const |
Public Member Functions inherited from gtsam::DecisionTree< Key, double > | |
| DecisionTree () | |
| DecisionTree (const double &y) | |
| DecisionTree (const Key &label, const double &y1, const double &y2) | |
Create tree with 2 assignments y1, y2, splitting on variable label More... | |
| DecisionTree (const LabelC &label, const double &y1, const double &y2) | |
| DecisionTree (const std::vector< LabelC > &labelCs, const std::vector< double > &ys) | |
| DecisionTree (const std::vector< LabelC > &labelCs, const std::string &table) | |
| DecisionTree (Iterator begin, Iterator end, const Key &label) | |
| DecisionTree (const Key &label, const DecisionTree &f0, const DecisionTree &f1) | |
| DecisionTree (const Unary &op, DecisionTree &&other) noexcept | |
Move constructor for DecisionTree. Very efficient as does not allocate anything, just changes in-place. But other is consumed. More... | |
| DecisionTree (const DecisionTree< Key, X > &other, Func Y_of_X) | |
| Convert from a different value type. More... | |
| DecisionTree (const DecisionTree< M, X > &other, const std::map< M, Key > &map, Func Y_of_X) | |
| Convert from a different value type X to value type Y, also translate labels via map from type M to L. More... | |
| void | print (const std::string &s, const LabelFormatter &labelFormatter, const ValueFormatter &valueFormatter) const |
| GTSAM-style print. More... | |
| bool | equals (const DecisionTree &other, const CompareFunc &compare=&DefaultCompare) const |
| virtual | ~DecisionTree ()=default |
| Make virtual. More... | |
| bool | empty () const |
| Check if tree is empty. More... | |
| bool | operator== (const DecisionTree &q) const |
| const double & | operator() (const Assignment< Key > &x) const |
| void | visit (Func f) const |
| Visit all leaves in depth-first fashion. More... | |
| void | visitLeaf (Func f) const |
| Visit all leaves in depth-first fashion. More... | |
| void | visitWith (Func f) const |
| Visit all leaves in depth-first fashion. More... | |
| size_t | nrLeaves () const |
| Return the number of leaves in the tree. More... | |
| X | fold (Func f, X x0) const |
| Fold a binary function over the tree, returning accumulator. More... | |
| std::set< Key > | labels () const |
| DecisionTree | apply (const Unary &op) const |
| DecisionTree | apply (const UnaryAssignment &op) const |
| Apply Unary operation "op" to f while also providing the corresponding assignment. More... | |
| DecisionTree | apply (const DecisionTree &g, const Binary &op) const |
| DecisionTree | choose (const Key &label, size_t index) const |
| DecisionTree | restrict (const Assignment< Key > &assignment) const |
| DecisionTree | combine (const Key &label, size_t cardinality, const Binary &op) const |
| DecisionTree | combine (const LabelC &labelC, const Binary &op) const |
| void | dot (std::ostream &os, const LabelFormatter &labelFormatter, const ValueFormatter &valueFormatter, bool showZero=true) const |
| void | dot (const std::string &name, const LabelFormatter &labelFormatter, const ValueFormatter &valueFormatter, bool showZero=true) const |
| std::string | dot (const LabelFormatter &labelFormatter, const ValueFormatter &valueFormatter, bool showZero=true) const |
| std::pair< DecisionTree< Key, A >, DecisionTree< Key, B > > | split (std::function< std::pair< A, B >(const double &)> AB_of_Y) const |
| Convert into two trees with value types A and B. More... | |
| DecisionTree (const NodePtr &root) | |
Standard Interface | |
| virtual double | evaluate (const Assignment< Key > &values) const override |
| double | error (const DiscreteValues &values) const override |
Calculate error for DiscreteValues x, is -log(probability). More... | |
| virtual DiscreteFactor::shared_ptr | multiply (const DiscreteFactor::shared_ptr &f) const override |
| Multiply factors, DiscreteFactor::shared_ptr edition. More... | |
| DiscreteFactor::shared_ptr | operator* (double s) const override |
| multiply with a scalar More... | |
| DecisionTreeFactor | operator* (const DecisionTreeFactor &f) const override |
| multiply two factors More... | |
| DecisionTreeFactor | operator/ (const DecisionTreeFactor &f) const |
Divide by factor f (safely). Division of a factor by another factor results in a function which involves all keys . More... | |
| DiscreteFactor::shared_ptr | operator/ (const DiscreteFactor::shared_ptr &f) const override |
| divide by DiscreteFactor::shared_ptr f (safely) More... | |
| DecisionTreeFactor | toDecisionTreeFactor () const override |
| Convert into a decision tree. More... | |
| DiscreteFactor::shared_ptr | sum (size_t nrFrontals) const override |
| Create new factor by summing all values with the same separator values. More... | |
| DiscreteFactor::shared_ptr | sum (const Ordering &keys) const override |
| Create new factor by summing all values with the same separator values. More... | |
| double | max () const override |
| Find the maximum value in the factor. More... | |
| DiscreteFactor::shared_ptr | max (size_t nrFrontals) const override |
| Create new factor by maximizing over all values with the same separator. More... | |
| DiscreteFactor::shared_ptr | max (const Ordering &keys) const override |
| Create new factor by maximizing over all values with the same separator. More... | |
| DiscreteFactor::shared_ptr | restrict (const DiscreteValues &assignment) const override |
| Restrict the factor to the given assignment. More... | |
| static double | safe_div (const double &a, const double &b) |
Additional Inherited Members | |
Static Public Member Functions inherited from gtsam::DecisionTree< Key, double > | |
| static NodePtr | compose (Iterator begin, Iterator end, const Key &label) |
Public Attributes inherited from gtsam::DecisionTree< Key, double > | |
| NodePtr | root_ |
| A DecisionTree just contains the root. TODO(dellaert): make protected. More... | |
Protected Member Functions inherited from gtsam::Factor | |
| Factor () | |
| template<typename CONTAINER > | |
| Factor (const CONTAINER &keys) | |
| template<typename ITERATOR > | |
| Factor (ITERATOR first, ITERATOR last) | |
Static Protected Member Functions inherited from gtsam::Factor | |
| template<typename CONTAINER > | |
| static Factor | FromKeys (const CONTAINER &keys) |
| template<typename ITERATOR > | |
| static Factor | FromIterators (ITERATOR first, ITERATOR last) |
Static Protected Member Functions inherited from gtsam::DecisionTree< Key, double > | |
| static NodePtr | build (It begin, It end, ValueIt beginY, ValueIt endY) |
| static NodePtr | convertFrom (const typename DecisionTree< Key, X >::NodePtr &f, std::function< double(const X &)> Y_of_X) |
| Convert from a DecisionTree<L, X> to DecisionTree<L, Y>. More... | |
| static NodePtr | convertFrom (const typename DecisionTree< M, X >::NodePtr &f, std::function< Key(const M &)> L_of_M, std::function< double(const X &)> Y_of_X) |
| Convert from a DecisionTree<M, X> to DecisionTree<L, Y>. More... | |
| static NodePtr | create (It begin, It end, ValueIt beginY, ValueIt endY) |
| static bool | DefaultCompare (const double &a, const double &b) |
| Default method for comparison of two objects of type Y. More... | |
Protected Attributes inherited from gtsam::DiscreteFactor | |
| std::map< Key, size_t > | cardinalities_ |
| Map of Keys and their cardinalities. More... | |
Protected Attributes inherited from gtsam::Factor | |
| KeyVector | keys_ |
| The keys involved in this factor. More... | |
A discrete probabilistic factor.
Definition at line 45 of file DecisionTreeFactor.h.
Definition at line 52 of file DecisionTreeFactor.h.
Typedef to base class.
Definition at line 50 of file DecisionTreeFactor.h.
| using gtsam::DiscreteFactor::Binary = std::function<double(const double, const double)> |
Definition at line 53 of file DiscreteFactor.h.
| typedef std::shared_ptr<DecisionTreeFactor> gtsam::DecisionTreeFactor::shared_ptr |
Definition at line 51 of file DecisionTreeFactor.h.
Definition at line 49 of file DecisionTreeFactor.h.
| using gtsam::DiscreteFactor::Unary = std::function<double(const double&)> |
Definition at line 50 of file DiscreteFactor.h.
| using gtsam::DiscreteFactor::UnaryAssignment = std::function<double(const Assignment<Key>&, const double&)> |
Definition at line 52 of file DiscreteFactor.h.
| gtsam::DecisionTreeFactor::DecisionTreeFactor | ( | ) |
Default constructor for I/O
Definition at line 33 of file DecisionTreeFactor.cpp.
| gtsam::DecisionTreeFactor::DecisionTreeFactor | ( | const DiscreteKeys & | keys, |
| const ADT & | potentials | ||
| ) |
Constructor from DiscreteKeys and AlgebraicDecisionTree
Definition at line 36 of file DecisionTreeFactor.cpp.
| gtsam::DecisionTreeFactor::DecisionTreeFactor | ( | const DiscreteKeys & | keys, |
| const std::vector< double > & | table | ||
| ) |
Constructor from doubles.
| keys | The discrete keys. |
| table | The table of values. |
| std::invalid_argument | if the size of table does not match the number of assignments. |
Example:
The values in the table should be laid out so that the first key varies the slowest, and the last key the fastest.
Definition at line 385 of file DecisionTreeFactor.cpp.
| gtsam::DecisionTreeFactor::DecisionTreeFactor | ( | const DiscreteKeys & | keys, |
| const std::string & | table | ||
| ) |
Constructor from string.
| keys | The discrete keys. |
| table | The table of values. |
| std::invalid_argument | if the size of table does not match the number of assignments. |
Example:
The values in the table should be laid out so that the first key varies the slowest, and the last key the fastest.
Definition at line 391 of file DecisionTreeFactor.cpp.
|
inline |
Single-key specialization.
Definition at line 112 of file DecisionTreeFactor.h.
|
inline |
Single-key specialization, with vector of doubles.
Definition at line 116 of file DecisionTreeFactor.h.
|
explicit |
Construct from a DiscreteConditional type
Definition at line 41 of file DecisionTreeFactor.cpp.
| DecisionTreeFactor gtsam::DecisionTreeFactor::apply | ( | const DecisionTreeFactor & | f, |
| Binary | op | ||
| ) | const |
Apply binary operator (*this) "op" f
| f | the second argument for op |
| op | a binary operator that operates on AlgebraicDecisionTree |
Definition at line 146 of file DecisionTreeFactor.cpp.
| DecisionTreeFactor gtsam::DecisionTreeFactor::apply | ( | Unary | op | ) | const |
Apply unary operator (*this) "op" f
| op | a unary operator that operates on AlgebraicDecisionTree |
Definition at line 130 of file DecisionTreeFactor.cpp.
| DecisionTreeFactor gtsam::DecisionTreeFactor::apply | ( | UnaryAssignment | op | ) | const |
Apply unary operator (*this) "op" f
| op | a unary operator that operates on AlgebraicDecisionTree. Takes both the assignment and the value. |
Definition at line 138 of file DecisionTreeFactor.cpp.
| DecisionTreeFactor::shared_ptr gtsam::DecisionTreeFactor::combine | ( | const Ordering & | keys, |
| Binary | op | ||
| ) | const |
Combine frontal variables in an Ordering using binary operator "op"
| nrFrontals | nr. of frontal to combine variables in this factor |
| op | a binary operator that operates on AlgebraicDecisionTree |
Definition at line 192 of file DecisionTreeFactor.cpp.
| DecisionTreeFactor::shared_ptr gtsam::DecisionTreeFactor::combine | ( | size_t | nrFrontals, |
| Binary | op | ||
| ) | const |
Combine frontal variables using binary operator "op"
| nrFrontals | nr. of frontal to combine variables in this factor |
| op | a binary operator that operates on AlgebraicDecisionTree |
Definition at line 165 of file DecisionTreeFactor.cpp.
| double gtsam::DecisionTreeFactor::computeThreshold | ( | const size_t | N | ) | const |
Compute the probability value which is the threshold above which only N leaves are present.
This is used for pruning out the smaller probabilities.
| N | The number of leaves to keep post pruning. |
Definition at line 454 of file DecisionTreeFactor.cpp.
| std::string gtsam::DecisionTreeFactor::dot | ( | const KeyFormatter & | keyFormatter = DefaultKeyFormatter, |
| bool | showZero = true |
||
| ) | const |
output to graphviz format string
Definition at line 313 of file DecisionTreeFactor.cpp.
| void gtsam::DecisionTreeFactor::dot | ( | const std::string & | name, |
| const KeyFormatter & | keyFormatter = DefaultKeyFormatter, |
||
| bool | showZero = true |
||
| ) | const |
output to graphviz format, open a file
Definition at line 306 of file DecisionTreeFactor.cpp.
| void gtsam::DecisionTreeFactor::dot | ( | std::ostream & | os, |
| const KeyFormatter & | keyFormatter = DefaultKeyFormatter, |
||
| bool | showZero = true |
||
| ) | const |
output to graphviz format, stream version
Definition at line 299 of file DecisionTreeFactor.cpp.
| std::vector< std::pair< DiscreteValues, double > > gtsam::DecisionTreeFactor::enumerate | ( | ) | const |
Enumerate all values into a map from values to double.
Definition at line 231 of file DecisionTreeFactor.cpp.
|
overridevirtual |
equality
Reimplemented from gtsam::DiscreteFactor.
Reimplemented in gtsam::DiscreteConditional, and gtsam::TableDistribution.
Definition at line 46 of file DecisionTreeFactor.cpp.
|
overridevirtual |
Calculate error for DiscreteValues x, is -log(probability).
Reimplemented from gtsam::DiscreteFactor.
Definition at line 57 of file DecisionTreeFactor.cpp.
|
overridevirtual |
Calculate error for HybridValues x, is -log(probability) Simply dispatches to DiscreteValues version.
Reimplemented from gtsam::Factor.
Definition at line 62 of file DecisionTreeFactor.cpp.
|
inlineoverridevirtual |
Calculate probability for given values, is just look up in AlgebraicDecisionTree.
Implements gtsam::DiscreteFactor.
Reimplemented in gtsam::TableDistribution.
Definition at line 140 of file DecisionTreeFactor.h.
|
overridevirtual |
Render as html table.
| keyFormatter | GTSAM-style Key formatter. |
| names | optional, category names corresponding to choices. |
Implements gtsam::DiscreteFactor.
Reimplemented in gtsam::DiscreteConditional.
Definition at line 351 of file DecisionTreeFactor.cpp.
|
overridevirtual |
Render as markdown table.
| keyFormatter | GTSAM-style Key formatter. |
| names | optional, category names corresponding to choices. |
Implements gtsam::DiscreteFactor.
Reimplemented in gtsam::DiscreteConditional.
Definition at line 320 of file DecisionTreeFactor.cpp.
|
inlineoverridevirtual |
Find the maximum value in the factor.
Implements gtsam::DiscreteFactor.
Reimplemented in gtsam::TableDistribution.
Definition at line 211 of file DecisionTreeFactor.h.
|
inlineoverridevirtual |
Create new factor by maximizing over all values with the same separator.
Implements gtsam::DiscreteFactor.
Reimplemented in gtsam::DiscreteConditional, and gtsam::TableDistribution.
Definition at line 219 of file DecisionTreeFactor.h.
|
inlineoverridevirtual |
Create new factor by maximizing over all values with the same separator.
Implements gtsam::DiscreteFactor.
Reimplemented in gtsam::TableDistribution.
Definition at line 214 of file DecisionTreeFactor.h.
|
overridevirtual |
Multiply factors, DiscreteFactor::shared_ptr edition.
This method accepts DiscreteFactor::shared_ptr and uses dynamic dispatch and specializations to perform the most efficient multiplication.
While converting a DecisionTreeFactor to a TableFactor is efficient, the reverse is not. Hence we specialize the code to return a TableFactor if f is a TableFactor, and DecisionTreeFactor otherwise.
| f | The factor to multiply with. |
Implements gtsam::DiscreteFactor.
Definition at line 67 of file DecisionTreeFactor.cpp.
|
inlineoverridevirtual |
Get the number of non-zero values contained in this factor. It could be much smaller than prod_{key}(cardinality(key)).
Implements gtsam::DiscreteFactor.
Reimplemented in gtsam::TableDistribution.
Definition at line 308 of file DecisionTreeFactor.h.
|
inlineoverridevirtual |
multiply two factors
Implements gtsam::DiscreteFactor.
Definition at line 174 of file DecisionTreeFactor.h.
|
inlineoverridevirtual |
multiply with a scalar
Implements gtsam::DiscreteFactor.
Reimplemented in gtsam::TableDistribution.
Definition at line 168 of file DecisionTreeFactor.h.
|
inline |
Divide by factor f (safely). Division of a factor
by another factor
results in a function which involves all keys
.
| f | The DecisinTreeFactor to divide by. |
Definition at line 189 of file DecisionTreeFactor.h.
|
overridevirtual |
divide by DiscreteFactor::shared_ptr f (safely)
Implements gtsam::DiscreteFactor.
Reimplemented in gtsam::TableDistribution.
Definition at line 91 of file DecisionTreeFactor.cpp.
|
overridevirtual |
Reimplemented from gtsam::Factor.
Reimplemented in gtsam::TableDistribution, gtsam::DiscreteDistribution, gtsam::DiscreteLookupTable, and gtsam::DiscreteConditional.
Definition at line 118 of file DecisionTreeFactor.cpp.
| std::vector< double > gtsam::DecisionTreeFactor::probabilities | ( | ) | const |
Get all the probabilities in order of assignment values.
Definition at line 248 of file DecisionTreeFactor.cpp.
| DecisionTreeFactor gtsam::DecisionTreeFactor::prune | ( | size_t | maxNrAssignments | ) | const |
Prune the decision tree of discrete variables.
Pruning will set the leaves to be "pruned" to 0 indicating a 0 probability. An assignment is pruned if it is not in the top maxNrAssignments values.
A violation can occur if there are more duplicate values than maxNrAssignments. A violation here is the need to un-prune the decision tree (e.g. all assignment values are 1.0). We could have another case where some subset of duplicates exist (e.g. for a tree with 8 assignments we have 1, 1, 1, 1, 0.8, 0.7, 0.6, 0.5), but this is not a violation since the for maxNrAssignments=5 the top values are (1, 0.8).
| maxNrAssignments | The maximum number of assignments to keep. |
Definition at line 512 of file DecisionTreeFactor.cpp.
|
overridevirtual |
Restrict the factor to the given assignment.
Implements gtsam::DiscreteFactor.
Definition at line 548 of file DecisionTreeFactor.cpp.
|
static |
Definition at line 110 of file DecisionTreeFactor.cpp.
|
inlineoverridevirtual |
Create new factor by summing all values with the same separator values.
Implements gtsam::DiscreteFactor.
Reimplemented in gtsam::TableDistribution.
Definition at line 206 of file DecisionTreeFactor.h.
|
inlineoverridevirtual |
Create new factor by summing all values with the same separator values.
Implements gtsam::DiscreteFactor.
Reimplemented in gtsam::TableDistribution.
Definition at line 201 of file DecisionTreeFactor.h.
|
inlineoverridevirtual |
Convert into a decision tree.
Implements gtsam::DiscreteFactor.
Reimplemented in gtsam::TableDistribution.
Definition at line 198 of file DecisionTreeFactor.h.