|
gtsam
|
A discrete probabilistic factor.
Standard Interface | |
| virtual double | evaluate (const Assignment< Key > &values) const override |
| Calculate probability for given values, is just look up in AlgebraicDecisionTree. | |
| double | error (const DiscreteValues &values) const override |
| Calculate error for DiscreteValues x, is -log(probability). | |
| virtual DiscreteFactor::shared_ptr | multiply (const DiscreteFactor::shared_ptr &f) const override |
| Multiply factors, DiscreteFactor::shared_ptr edition. | |
| DiscreteFactor::shared_ptr | operator* (double s) const override |
| multiply with a scalar | |
| DecisionTreeFactor | operator* (const DecisionTreeFactor &f) const override |
| multiply two factors | |
| DecisionTreeFactor | operator/ (const DecisionTreeFactor &f) const |
| Divide by factor f (safely). | |
| DiscreteFactor::shared_ptr | operator/ (const DiscreteFactor::shared_ptr &f) const override |
| divide by DiscreteFactor::shared_ptr f (safely) | |
| DecisionTreeFactor | toDecisionTreeFactor () const override |
| Convert into a decision tree. | |
| TableFactor | toTableFactor () const override |
| Convert directly into a sparse table. | |
| DiscreteFactor::shared_ptr | sum (size_t nrFrontals) const override |
| Create new factor by summing all values with the same separator values. | |
| DiscreteFactor::shared_ptr | sum (const Ordering &keys) const override |
| Create new factor by summing all values with the same separator values. | |
| double | max () const override |
| Find the maximum value in the factor. | |
| DiscreteFactor::shared_ptr | max (size_t nrFrontals) const override |
| Create new factor by maximizing over all values with the same separator. | |
| DiscreteFactor::shared_ptr | max (const Ordering &keys) const override |
| Create new factor by maximizing over all values with the same separator. | |
| DiscreteFactor::shared_ptr | restrict (const DiscreteValues &assignment) const override |
| Restrict the factor to the given assignment. | |
| double | operator() (const DiscreteValues &values) const |
| Disambiguate to use DiscreteFactor version. Mainly for wrapper. | |
| double | sum () const |
| Use sum() from AlgebraicDecisionTree. | |
| AlgebraicDecisionTree | sum (const Key &label, size_t cardinality) const |
| Use sum() from AlgebraicDecisionTree. | |
| AlgebraicDecisionTree | sum (const typename Base::LabelC &labelC) const |
| Use sum() from AlgebraicDecisionTree. | |
| static double | safe_div (const double &a, const double &b) |
Public Member Functions | |
Standard Constructors | |
| DecisionTreeFactor () | |
| Default constructor for I/O. | |
| DecisionTreeFactor (const DiscreteKeys &keys, const ADT &potentials) | |
| Constructor from DiscreteKeys and AlgebraicDecisionTree. | |
| DecisionTreeFactor (const DiscreteKeys &keys, const std::vector< double > &table) | |
| Constructor from doubles. | |
| DecisionTreeFactor (const DiscreteKeys &keys, const std::string &table) | |
| Constructor from string. | |
| template<class SOURCE> | |
| DecisionTreeFactor (const DiscreteKey &key, SOURCE table) | |
| Single-key specialization. | |
| DecisionTreeFactor (const DiscreteKey &key, const std::vector< double > &row) | |
| Single-key specialization, with vector of doubles. | |
| DecisionTreeFactor (const DiscreteConditional &c) | |
| Construct from a DiscreteConditional type. | |
Testable | |
| bool | equals (const DiscreteFactor &other, double tol=1e-9) const override |
| equality | |
| void | print (const std::string &s="DecisionTreeFactor:\n", const KeyFormatter &formatter=DefaultKeyFormatter) const override |
| print | |
Advanced Interface | |
| DecisionTreeFactor | apply (Unary op) const |
| Apply unary operator (*this) "op" f. | |
| DecisionTreeFactor | apply (UnaryAssignment op) const |
| Apply unary operator (*this) "op" f. | |
| DecisionTreeFactor | apply (const DecisionTreeFactor &f, Binary op) const |
| Apply binary operator (*this) "op" f. | |
| shared_ptr | combine (size_t nrFrontals, Binary op) const |
| Combine frontal variables using binary operator "op". | |
| shared_ptr | combine (const Ordering &keys, Binary op) const |
| Combine frontal variables in an Ordering using binary operator "op". | |
| std::vector< std::pair< DiscreteValues, double > > | enumerate () const |
| Enumerate all values into a map from values to double. | |
| std::vector< double > | probabilities () const |
| Get all the probabilities in order of assignment values. | |
| double | computeThreshold (const size_t N) const |
| Compute the probability value which is the threshold above which only N leaves are present. | |
| DecisionTreeFactor | prune (size_t maxNrAssignments) const |
| Prune the decision tree of discrete variables. | |
| uint64_t | nrValues () const override |
| Get the number of non-zero values contained in this factor. | |
Wrapper support | |
| void | dot (std::ostream &os, const KeyFormatter &keyFormatter=DefaultKeyFormatter, bool showZero=true) const |
| output to graphviz format, stream version | |
| void | dot (const std::string &name, const KeyFormatter &keyFormatter=DefaultKeyFormatter, bool showZero=true) const |
| output to graphviz format, open a file | |
| std::string | dot (const KeyFormatter &keyFormatter=DefaultKeyFormatter, bool showZero=true) const |
| output to graphviz format string | |
| std::string | markdown (const KeyFormatter &keyFormatter=DefaultKeyFormatter, const Names &names={}) const override |
| Render as markdown table. | |
| std::string | html (const KeyFormatter &keyFormatter=DefaultKeyFormatter, const Names &names={}) const override |
| Render as html table. | |
HybridValues methods. | |
| double | error (const HybridValues &values) const override |
| Calculate error for HybridValues x, is -log(probability) Simply dispatches to DiscreteValues version. | |
| Public Member Functions inherited from gtsam::DiscreteFactor | |
| DiscreteFactor () | |
| Default constructor creates empty factor. | |
| template<typename CONTAINER> | |
| DiscreteFactor (const CONTAINER &keys, const std::map< Key, size_t > cardinalities={}) | |
| Construct from container of keys and map of cardinalities. | |
| void | print (const std::string &s="DiscreteFactor\n", const KeyFormatter &formatter=DefaultKeyFormatter) const override |
| print | |
| DiscreteKeys | discreteKeys () const |
| Return all the discrete keys associated with this factor. | |
| 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. | |
| double | error (const HybridValues &c) const override |
| All factor types need to implement an error function. | |
| virtual AlgebraicDecisionTree< Key > | errorTree () const |
| Compute error for each assignment and return as a tree. | |
| DiscreteFactor::shared_ptr | scale () const |
| Scale the factor values by the maximum to prevent underflow/overflow. | |
| Public Member Functions inherited from gtsam::Factor | |
| virtual | ~Factor ()=default |
| Default destructor. | |
| bool | empty () const |
| Whether the factor is empty (involves zero variables). | |
| Key | front () const |
| First key. | |
| Key | back () const |
| Last key. | |
| const_iterator | find (Key key) const |
| find | |
| const KeyVector & | keys () const |
| Access the factor's involved variable keys. | |
| const_iterator | begin () const |
| Iterator at beginning of involved variable keys. | |
| const_iterator | end () const |
| Iterator at end of involved variable keys. | |
| size_t | size () const |
| virtual void | printKeys (const std::string &s="Factor", const KeyFormatter &formatter=DefaultKeyFormatter) const |
| print only keys | |
| bool | equals (const This &other, double tol=1e-9) const |
| check equality | |
| KeyVector & | keys () |
| iterator | begin () |
| Iterator at beginning of involved variable keys. | |
| iterator | end () |
| Iterator at end of involved variable keys. | |
| Public Member Functions inherited from gtsam::AlgebraicDecisionTree< Key > | |
| AlgebraicDecisionTree (double leaf=1.0) | |
| AlgebraicDecisionTree (const typename Base::NodePtr root) | |
| Constructor which accepts root pointer. | |
| AlgebraicDecisionTree (const Base &add) | |
| AlgebraicDecisionTree (const Key &label, double y1, double y2) | |
| Create a new leaf function splitting on a variable. | |
| AlgebraicDecisionTree (const typename Base::LabelC &labelC, double y1, double y2) | |
| Create a new leaf function splitting on a variable. | |
| AlgebraicDecisionTree (const std::vector< typename Base::LabelC > &labelCs, const std::vector< double > &ys) | |
| Create from keys with cardinalities and a vector table. | |
| AlgebraicDecisionTree (const std::vector< typename Base::LabelC > &labelCs, const std::string &table) | |
| Create from keys and string table. | |
| AlgebraicDecisionTree (Iterator begin, Iterator end, const Key &label) | |
| Create a range of decision trees, splitting on a single variable. | |
| AlgebraicDecisionTree (const AlgebraicDecisionTree< M > &other, const std::map< M, Key > &map) | |
| Convert labels from type M to type L. | |
| AlgebraicDecisionTree (const DecisionTree< Key, X > &other, Func f) | |
| Create from an arbitrary DecisionTree<L, X> by operating on it with a functional f. | |
| AlgebraicDecisionTree | operator+ (const AlgebraicDecisionTree &g) const |
| sum | |
| AlgebraicDecisionTree | operator- () const |
| negation | |
| AlgebraicDecisionTree | operator- (const AlgebraicDecisionTree &g) const |
| subtract | |
| AlgebraicDecisionTree | operator* (const AlgebraicDecisionTree &g) const |
| product | |
| AlgebraicDecisionTree | operator/ (const AlgebraicDecisionTree &g) const |
| division | |
| double | sum () const |
| Compute sum of all values. | |
| AlgebraicDecisionTree | normalize () const |
| Helper method to perform normalization such that all leaves in the tree sum to 1. | |
| double | min () const |
| Find the minimum values amongst all leaves. | |
| double | max () const |
| Find the maximum values amongst all leaves. | |
| AlgebraicDecisionTree | sum (const Key &label, size_t cardinality) const |
| sum out variable | |
| AlgebraicDecisionTree | sum (const typename Base::LabelC &labelC) const |
| sum out variable | |
| void | print (const std::string &s="", const typename Base::LabelFormatter &labelFormatter=&DefaultFormatter) const |
| print method customized to value type double. | |
| bool | equals (const AlgebraicDecisionTree &other, double tol=1e-9) const |
| Equality method customized to value type double. | |
| Public Member Functions inherited from gtsam::DecisionTree< L, Y > | |
| DecisionTree () | |
| Default constructor (for serialization). | |
| DecisionTree (const Y &y) | |
| Create a constant. | |
| DecisionTree (const L &label, const Y &y1, const Y &y2) | |
| Create tree with 2 assignments y1, y2, splitting on variable label. | |
| DecisionTree (const LabelC &label, const Y &y1, const Y &y2) | |
| Allow Label+Cardinality for convenience. | |
| DecisionTree (const std::vector< LabelC > &labelCs, const std::vector< Y > &ys) | |
| Create from keys and a corresponding vector of values. | |
| DecisionTree (const std::vector< LabelC > &labelCs, const std::string &table) | |
| Create from keys and string table. | |
| template<typename Iterator> | |
| DecisionTree (Iterator begin, Iterator end, const L &label) | |
| Create DecisionTree from others. | |
| DecisionTree (const L &label, const DecisionTree &f0, const DecisionTree &f1) | |
| Create DecisionTree from two others. | |
| DecisionTree (const Unary &op, DecisionTree &&other) noexcept | |
| Move constructor for DecisionTree. | |
| template<typename X, typename Func> | |
| DecisionTree (const DecisionTree< L, X > &other, Func Y_of_X) | |
| Convert from a different value type. | |
| template<typename M, typename X, typename Func> | |
| DecisionTree (const DecisionTree< M, X > &other, const std::map< M, L > &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. | |
| void | print (const std::string &s, const LabelFormatter &labelFormatter, const ValueFormatter &valueFormatter) const |
| GTSAM-style print. | |
| bool | equals (const DecisionTree &other, const CompareFunc &compare=&DefaultCompare) const |
| virtual | ~DecisionTree ()=default |
| Make virtual. | |
| bool | empty () const |
| Check if tree is empty. | |
| bool | operator== (const DecisionTree &q) const |
| equality | |
| const Y & | operator() (const Assignment< L > &x) const |
| evaluate | |
| template<typename Func> | |
| void | visit (Func f) const |
| Visit all leaves in depth-first fashion. | |
| template<typename Func> | |
| void | visitLeaf (Func f) const |
| Visit all leaves in depth-first fashion. | |
| template<typename Func> | |
| void | visitWith (Func f) const |
| Visit all leaves in depth-first fashion. | |
| size_t | nrLeaves () const |
| Return the number of leaves in the tree. | |
| template<typename Func, typename X> | |
| X | fold (Func f, X x0) const |
| Fold a binary function over the tree, returning accumulator. | |
| std::set< L > | labels () const |
| Retrieve all unique labels as a set. | |
| DecisionTree | apply (const Unary &op) const |
| apply Unary operation "op" to f | |
| DecisionTree | apply (const UnaryAssignment &op) const |
| Apply Unary operation "op" to f while also providing the corresponding assignment. | |
| DecisionTree | apply (const DecisionTree &g, const Binary &op) const |
| apply binary operation "op" to f and g | |
| DecisionTree | choose (const L &label, size_t index) const |
| create a new function where value(label)==index It's like "restrict" in Darwiche09book pg329, 330? | |
| DecisionTree | restrict (const Assignment< L > &assignment) const |
| Choose multiple values. | |
| DecisionTree | combine (const L &label, size_t cardinality, const Binary &op) const |
| combine subtrees on key with binary operation "op" | |
| DecisionTree | combine (const LabelC &labelC, const Binary &op) const |
| combine with LabelC for convenience | |
| void | dot (std::ostream &os, const LabelFormatter &labelFormatter, const ValueFormatter &valueFormatter, bool showZero=true) const |
| output to graphviz format, stream version | |
| void | dot (const std::string &name, const LabelFormatter &labelFormatter, const ValueFormatter &valueFormatter, bool showZero=true) const |
| output to graphviz format, open a file | |
| std::string | dot (const LabelFormatter &labelFormatter, const ValueFormatter &valueFormatter, bool showZero=true) const |
| output to graphviz format string | |
| template<typename A, typename B> | |
| std::pair< DecisionTree< L, A >, DecisionTree< L, B > > | split (std::function< std::pair< A, B >(const Y &)> AB_of_Y) const |
| Convert into two trees with value types A and B. | |
| DecisionTree (const NodePtr &root) | |
Public Types | |
| typedef DecisionTreeFactor | This |
| typedef DiscreteFactor | Base |
| Typedef to base class. | |
| typedef std::shared_ptr< DecisionTreeFactor > | shared_ptr |
| typedef AlgebraicDecisionTree< Key > | ADT |
| using | Binary |
| using | Unary |
| using | UnaryAssignment |
| Public Types inherited from gtsam::DiscreteFactor | |
| typedef DiscreteFactor | This |
| This class. | |
| typedef std::shared_ptr< DiscreteFactor > | shared_ptr |
| shared_ptr to this class | |
| typedef Factor | Base |
| Our base class. | |
| using | Values = DiscreteValues |
| backwards compatibility | |
| using | Unary = std::function<double(const double&)> |
| using | UnaryAssignment |
| using | Binary = std::function<double(const double, const double)> |
| using | Names = DiscreteValues::Names |
| Translation table from values to strings. | |
| Public Types inherited from gtsam::Factor | |
| typedef KeyVector::iterator | iterator |
| Iterator over keys. | |
| typedef KeyVector::const_iterator | const_iterator |
| Const iterator over keys. | |
| Public Types inherited from gtsam::AlgebraicDecisionTree< Key > | |
| using | Base |
| Public Types inherited from gtsam::DecisionTree< L, Y > | |
| using | LabelFormatter = std::function<std::string(L)> |
| using | ValueFormatter = std::function<std::string(Y)> |
| using | CompareFunc = std::function<bool(const Y&, const Y&)> |
| using | Unary = std::function<Y(const Y&)> |
| Handy typedefs for unary and binary function types. | |
| using | UnaryAssignment = std::function<Y(const Assignment<L>&, const Y&)> |
| using | Binary = std::function<Y(const Y&, const Y&)> |
| using | LabelC = std::pair<L, size_t> |
| A label annotated with cardinality. | |
| using | NodePtr = typename Node::Ptr |
| ---------------------— Node base class ------------------------— | |
Additional Inherited Members | |
| template<typename Iterator> | |
| static NodePtr | compose (Iterator begin, Iterator end, const L &label) |
| Public Attributes inherited from gtsam::DecisionTree< L, Y > | |
| NodePtr | root_ |
| A DecisionTree just contains the root. TODO(dellaert): make protected. | |
| Factor () | |
| Default constructor for I/O. | |
| template<typename CONTAINER> | |
| Factor (const CONTAINER &keys) | |
| Construct factor from container of keys. | |
| template<typename ITERATOR> | |
| Factor (ITERATOR first, ITERATOR last) | |
| Construct factor from iterator keys. | |
| template<typename CONTAINER> | |
| static Factor | FromKeys (const CONTAINER &keys) |
| Construct factor from container of keys. | |
| template<typename ITERATOR> | |
| static Factor | FromIterators (ITERATOR first, ITERATOR last) |
| Construct factor from iterator keys. | |
| Static Protected Member Functions inherited from gtsam::DecisionTree< L, Y > | |
| static bool | DefaultCompare (const Y &a, const Y &b) |
| Default method for comparison of two objects of type Y. | |
| template<typename It, typename ValueIt> | |
| static NodePtr | build (It begin, It end, ValueIt beginY, ValueIt endY) |
| Internal recursive function to create from keys, cardinalities, and Y values. | |
| template<typename It, typename ValueIt> | |
| static NodePtr | create (It begin, It end, ValueIt beginY, ValueIt endY) |
| Internal helper function to create a tree from keys, cardinalities, and Y values. | |
| template<typename X> | |
| static NodePtr | convertFrom (const typename DecisionTree< L, X >::NodePtr &f, std::function< Y(const X &)> Y_of_X) |
| Convert from a DecisionTree<L, X> to DecisionTree<L, Y>. | |
| template<typename M, typename X> | |
| static NodePtr | convertFrom (const typename DecisionTree< M, X >::NodePtr &f, std::function< L(const M &)> L_of_M, std::function< Y(const X &)> Y_of_X) |
| Convert from a DecisionTree<M, X> to DecisionTree<L, Y>. | |
| Protected Attributes inherited from gtsam::DiscreteFactor | |
| std::map< Key, size_t > | cardinalities_ |
| Map of Keys and their cardinalities. | |
| Protected Attributes inherited from gtsam::Factor | |
| KeyVector | keys_ |
| The keys involved in this factor. | |
| 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.
| 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.
| 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 |
| DecisionTreeFactor gtsam::DecisionTreeFactor::apply | ( | Unary | op | ) | const |
Apply unary operator (*this) "op" f.
| op | a unary operator that operates on AlgebraicDecisionTree |
| 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. |
| 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 |
| 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 |
| 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. |
|
overridevirtual |
equality
Reimplemented from gtsam::DiscreteFactor.
Reimplemented in gtsam::DiscreteConditional, and gtsam::TableDistribution.
|
overridevirtual |
Calculate error for DiscreteValues x, is -log(probability).
Reimplemented from gtsam::DiscreteFactor.
Reimplemented in gtsam::DiscreteConditional.
|
overridevirtual |
Calculate error for HybridValues x, is -log(probability) Simply dispatches to DiscreteValues version.
Reimplemented from gtsam::Factor.
Reimplemented in gtsam::DiscreteConditional.
|
inlineoverridevirtual |
Calculate probability for given values, is just look up in AlgebraicDecisionTree.
Implements gtsam::DiscreteFactor.
Reimplemented in gtsam::DiscreteConditional, and gtsam::TableDistribution.
|
overridevirtual |
Render as html table.
| keyFormatter | GTSAM-style Key formatter. |
| names | optional, category names corresponding to choices. |
Implements gtsam::DiscreteFactor.
Reimplemented in gtsam::DiscreteConditional.
|
overridevirtual |
Render as markdown table.
| keyFormatter | GTSAM-style Key formatter. |
| names | optional, category names corresponding to choices. |
Implements gtsam::DiscreteFactor.
Reimplemented in gtsam::DiscreteConditional.
|
inlineoverridevirtual |
Find the maximum value in the factor.
Implements gtsam::DiscreteFactor.
Reimplemented in gtsam::TableDistribution.
|
inlineoverridevirtual |
Create new factor by maximizing over all values with the same separator.
Implements gtsam::DiscreteFactor.
Reimplemented in gtsam::DiscreteConditional, and gtsam::TableDistribution.
|
inlineoverridevirtual |
Create new factor by maximizing over all values with the same separator.
Implements gtsam::DiscreteFactor.
Reimplemented in gtsam::TableDistribution.
|
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. |
Reimplemented from gtsam::DiscreteFactor.
|
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.
|
inlineoverridevirtual |
multiply two factors
Implements gtsam::DiscreteFactor.
Reimplemented in gtsam::DiscreteBoundaryFactor, and gtsam::DiscreteConditional.
|
inlineoverridevirtual |
multiply with a scalar
Implements gtsam::DiscreteFactor.
Reimplemented in gtsam::DiscreteBoundaryFactor, gtsam::DiscreteConditional, and gtsam::TableDistribution.
|
inline |
Divide by factor f (safely).
Division of a factor \(f(x, y)\) by another factor \(g(y, z)\) results in a function which involves all keys \((\frac{f}{g})(x, y, z) = f(x, y) / g(y, z)\)
| f | The DecisinTreeFactor to divide by. |
|
overridevirtual |
divide by DiscreteFactor::shared_ptr f (safely)
Implements gtsam::DiscreteFactor.
Reimplemented in gtsam::DiscreteBoundaryFactor, and gtsam::TableDistribution.
|
overridevirtual |
Reimplemented from gtsam::Factor.
Reimplemented in gtsam::DiscreteBoundaryFactor, gtsam::DiscreteConditional, gtsam::DiscreteDistribution, gtsam::DiscreteLookupTable, and gtsam::TableDistribution.
| 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. |
|
overridevirtual |
Restrict the factor to the given assignment.
Implements gtsam::DiscreteFactor.
|
inlineoverridevirtual |
Create new factor by summing all values with the same separator values.
Implements gtsam::DiscreteFactor.
Reimplemented in gtsam::TableDistribution.
|
inlineoverridevirtual |
Create new factor by summing all values with the same separator values.
Implements gtsam::DiscreteFactor.
Reimplemented in gtsam::TableDistribution.
|
inlineoverridevirtual |
Convert into a decision tree.
Implements gtsam::DiscreteFactor.
Reimplemented in gtsam::TableDistribution.
|
overridevirtual |
Convert directly into a sparse table.
Reimplemented from gtsam::DiscreteFactor.
Reimplemented in gtsam::TableDistribution.