Go to the documentation of this file.
31 using namespace gtsam;
39 const std::vector<double>
table{2, 5, 3, 6, 4, 7};
84 vector<double>{-0.69314718, -1.6094379, -1.0986123, -1.7917595,
85 -1.3862944, -1.9459101, -3.2188758, -4.0073332, -3.5553481,
86 -4.1743873, -3.8066625, -4.3174881});
131 std::vector<std::pair<DiscreteValues, double>>
expected;
133 for (
size_t a : {0, 1, 2}) {
134 for (
size_t b : {0, 1}) {
151 "0.0 0.0 0.0 0.60658897 0.61241912 0.61241969 0.61247685 0.61247742 0.0 "
152 "0.0 0.0 0.99995287 1.0 1.0 1.0 1.0");
185 size_t maxNrAssignments = 5;
186 auto pruned5 =
f.
prune(maxNrAssignments);
193 maxNrAssignments = 2;
194 auto pruned2 =
f.
prune(maxNrAssignments);
199 "0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 "
200 "0.999952870000 1.0 1.0 1.0 1.0");
201 maxNrAssignments = 5;
214 std::vector<std::string>
names = {
"A",
"S",
"T",
"L",
"B",
"E",
"X",
"D"};
229 DiscreteKey A(0, 2),
S(1, 2),
T(2, 2),
L(3, 2),
B(4, 2),
E(5, 2),
X(6, 2),
276 for (
bool showZero : {
true,
false}) {
317 auto keyFormatter = [](
Key key) {
return key == 12 ?
"A" :
"B"; };
318 DecisionTreeFactor::Names
names{{12, {
"Zero",
"One",
"Two"}},
331 "<table class='DecisionTreeFactor'>\n"
333 " <tr><th>A</th><th>B</th><th>value</th></tr>\n"
336 " <tr><th>Zero</th><th>-</th><td>1</td></tr>\n"
337 " <tr><th>Zero</th><th>+</th><td>2</td></tr>\n"
338 " <tr><th>One</th><th>-</th><td>3</td></tr>\n"
339 " <tr><th>One</th><th>+</th><td>4</td></tr>\n"
340 " <tr><th>Two</th><th>-</th><td>5</td></tr>\n"
341 " <tr><th>Two</th><th>+</th><td>6</td></tr>\n"
345 auto keyFormatter = [](
Key key) {
return key == 12 ?
"A" :
"B"; };
346 DecisionTreeFactor::Names
names{{12, {
"Zero",
"One",
"Two"}},
std::vector< double > cpt() const
static int runAllTests(TestResult &result)
virtual AlgebraicDecisionTree< Key > errorTree() const
Compute error for each assignment and return as a tree.
string markdown(const DiscreteValues &values, const KeyFormatter &keyFormatter, const DiscreteValues::Names &names)
Free version of markdown.
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
double computeThreshold(const size_t N) const
Compute the probability value which is the threshold above which only N leaves are present.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
#define EXPECT_LONGS_EQUAL(expected, actual)
Concept check for values that can be used in unit tests.
#define EXPECT(condition)
void dot(std::ostream &os, const KeyFormatter &keyFormatter=DefaultKeyFormatter, bool showZero=true) const
GaussianFactorGraphValuePair Y
DecisionTreeFactor f(A &B &C, "1 5 3 7 2 6 4 8")
DecisionTreeFactor prune(size_t maxNrAssignments) const
Prune the decision tree of discrete variables.
void maybeSaveDotFile(const DecisionTreeFactor &f, const string &filename)
const KeyFormatter & formatter
double f2(const Vector2 &x)
Eigen::Triplet< double > T
const EIGEN_DEVICE_FUNC LogReturnType log() const
Variable ordering for the elimination algorithm.
TEST(DecisionTreeFactor, ConstructorsMatch)
DecisionTreeFactor create(const Signature &signature)
std::shared_ptr< DecisionTreeFactor > shared_ptr
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
DecisionTreeFactor factor(D &C &B &A, "0.0 0.0 0.0 0.60658897 0.61241912 0.61241969 0.61247685 0.61247742 0.0 " "0.0 0.0 0.99995287 1.0 1.0 1.0 1.0")
signatures for conditional densities
#define EXPECT_DOUBLES_EQUAL(expected, actual, threshold)
shared_ptr sum(size_t nrFrontals) const
Create new factor by summing all values with the same separator values.
const gtsam::Symbol key('X', 0)
double f3(double x1, double x2)
std::pair< Key, size_t > DiscreteKey
std::string html(const KeyFormatter &keyFormatter=DefaultKeyFormatter, const Names &names={}) const override
Render as html table.
double f4(double x, double y, double z)
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
std::vector< std::pair< DiscreteValues, double > > enumerate() const
Enumerate all values into a map from values to double.
DiscreteKeys discreteKeys() const
DiscreteKeys discreteKeys() const
Return all the discrete keys associated with this factor.
std::uint64_t Key
Integer nonlinear key type.
std::string markdown(const KeyFormatter &keyFormatter=DefaultKeyFormatter, const Names &names={}) const override
Render as markdown table.
gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:16:13