use existing cardinalities
parent
3d24d0128f
commit
5f83464f0d
|
|
@ -196,18 +196,12 @@ namespace gtsam {
|
||||||
|
|
||||||
/* ************************************************************************ */
|
/* ************************************************************************ */
|
||||||
std::vector<double> DecisionTreeFactor::probabilities() const {
|
std::vector<double> DecisionTreeFactor::probabilities() const {
|
||||||
std::vector<double> probs;
|
|
||||||
|
|
||||||
// Get all the key cardinalities
|
|
||||||
std::map<Key, size_t> cardins;
|
|
||||||
for (auto [key, cardinality] : discreteKeys()) {
|
|
||||||
cardins[key] = cardinality;
|
|
||||||
}
|
|
||||||
// Set of all keys
|
// Set of all keys
|
||||||
std::set<Key> allKeys(keys().begin(), keys().end());
|
std::set<Key> allKeys(keys().begin(), keys().end());
|
||||||
|
|
||||||
|
std::vector<double> probs;
|
||||||
|
|
||||||
// Go through the tree
|
// Go through the tree
|
||||||
std::vector<double> ys;
|
|
||||||
this->apply([&](const Assignment<Key> a, double p) {
|
this->apply([&](const Assignment<Key> a, double p) {
|
||||||
// Get all the keys in the current assignment
|
// Get all the keys in the current assignment
|
||||||
std::set<Key> assignment_keys;
|
std::set<Key> assignment_keys;
|
||||||
|
|
@ -224,7 +218,7 @@ namespace gtsam {
|
||||||
// Compute the total number of assignments in the (pruned) subtree
|
// Compute the total number of assignments in the (pruned) subtree
|
||||||
size_t nrAssignments = 1;
|
size_t nrAssignments = 1;
|
||||||
for (auto&& k : diff) {
|
for (auto&& k : diff) {
|
||||||
nrAssignments *= cardins.at(k);
|
nrAssignments *= cardinalities_.at(k);
|
||||||
}
|
}
|
||||||
probs.insert(probs.end(), nrAssignments, p);
|
probs.insert(probs.end(), nrAssignments, p);
|
||||||
return p;
|
return p;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue