2828namespace gtsam {
2929
3030 /* *
31- * Algebraic Decision Trees fix the range to double
32- * Just has some nice constructors and some syntactic sugar
33- * TODO: consider eliminating this class altogether?
31+ * An algebraic decision tree fixes the range of a DecisionTree to double.
32+ * Just has some nice constructors and some syntactic sugar.
33+ * TODO(dellaert) : consider eliminating this class altogether?
3434 *
3535 * @ingroup discrete
3636 */
@@ -80,20 +80,62 @@ namespace gtsam {
8080 AlgebraicDecisionTree (const L& label, double y1, double y2)
8181 : Base(label, y1, y2) {}
8282
83- /* * Create a new leaf function splitting on a variable */
83+ /* *
84+ * @brief Create a new leaf function splitting on a variable
85+ *
86+ * @param labelC: The label with cardinality 2
87+ * @param y1: The value for the first key
88+ * @param y2: The value for the second key
89+ *
90+ * Example:
91+ * @code{.cpp}
92+ * std::pair<string, size_t> A {"a", 2};
93+ * AlgebraicDecisionTree<string> a(A, 0.6, 0.4);
94+ * @endcode
95+ */
8496 AlgebraicDecisionTree (const typename Base::LabelC& labelC, double y1,
8597 double y2)
8698 : Base(labelC, y1, y2) {}
8799
88- /* * Create from keys and vector table */
100+ /* *
101+ * @brief Create from keys with cardinalities and a vector table
102+ *
103+ * @param labelCs: The keys, with cardinalities, given as pairs
104+ * @param ys: The vector table
105+ *
106+ * Example with three keys, A, B, and C, with cardinalities 2, 3, and 2,
107+ * respectively, and a vector table of size 12:
108+ * @code{.cpp}
109+ * DiscreteKey A(0, 2), B(1, 3), C(2, 2);
110+ * const vector<double> cpt{
111+ * 1.0 / 3, 2.0 / 3, 3.0 / 7, 4.0 / 7, 5.0 / 11, 6.0 / 11, //
112+ * 1.0 / 9, 8.0 / 9, 3.0 / 6, 3.0 / 6, 5.0 / 10, 5.0 / 10};
113+ * AlgebraicDecisionTree<Key> expected(A & B & C, cpt);
114+ * @endcode
115+ * The table is given in the following order:
116+ * A=0, B=0, C=0
117+ * A=0, B=0, C=1
118+ * ...
119+ * A=1, B=1, C=1
120+ * Hence, the first line in the table is for A==0, and the second for A==1.
121+ * In each line, the first two entries are for B==0, the next two for B==1,
122+ * and the last two for B==2. Each pair is for a C value of 0 and 1.
123+ */
89124 AlgebraicDecisionTree //
90125 (const std::vector<typename Base::LabelC>& labelCs,
91- const std::vector<double >& ys) {
126+ const std::vector<double >& ys) {
92127 this ->root_ =
93128 Base::create (labelCs.begin (), labelCs.end (), ys.begin (), ys.end ());
94129 }
95130
96- /* * Create from keys and string table */
131+ /* *
132+ * @brief Create from keys and string table
133+ *
134+ * @param labelCs: The keys, with cardinalities, given as pairs
135+ * @param table: The string table, given as a string of doubles.
136+ *
137+ * @note Table needs to be in same order as the vector table in the other constructor.
138+ */
97139 AlgebraicDecisionTree //
98140 (const std::vector<typename Base::LabelC>& labelCs,
99141 const std::string& table) {
@@ -108,7 +150,13 @@ namespace gtsam {
108150 Base::create (labelCs.begin (), labelCs.end (), ys.begin (), ys.end ());
109151 }
110152
111- /* * Create a new function splitting on a variable */
153+ /* *
154+ * @brief Create a range of decision trees, splitting on a single variable.
155+ *
156+ * @param begin: Iterator to beginning of a range of decision trees
157+ * @param end: Iterator to end of a range of decision trees
158+ * @param label: The label to split on
159+ */
112160 template <typename Iterator>
113161 AlgebraicDecisionTree (Iterator begin, Iterator end, const L& label)
114162 : Base(nullptr ) {
0 commit comments