Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AlgebraicDecisionTree Helpers #1696

Merged
merged 54 commits into from
Aug 21, 2024
Merged

Conversation

varunagrawal
Copy link
Collaborator

@varunagrawal varunagrawal commented Dec 21, 2023

This PR does two primary things:

  1. Helpful methods (min, max, sum, etc) in AlgebraicDecisionTree.
  2. Lots of formatting.

(NOTE: I broke down a much larger PR into this smaller one. Will create additional PRs with the rest of the changes)

@varunagrawal varunagrawal self-assigned this Dec 21, 2023
@@ -220,15 +220,103 @@ GaussianBayesNet HybridBayesNet::choose(
/* ************************************************************************* */
HybridValues HybridBayesNet::optimize() const {
// Collect all the discrete factors to compute MPE
DiscreteBayesNet discrete_bn;
DiscreteFactorGraph discrete_fg;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is way too large to properly understand. Please break up?

// the unnormalized probability q(μ;m) = exp(-error(μ;m)) at the mean.
// discrete_probability = exp(-error(μ;m)) * sqrt(det(2π Σ_m))
auto probability = [&](const Result &pair) -> double {
// Compute the probability q(μ;m) = exp(-error(μ;m)) * sqrt(det(2π Σ_m))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I guess this will conflict with my simplified PR...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we should probably land all of my old PRs so we can reduce conflicts.

return - 0.5 * n * log2pi + logDeterminant();
// Sigma = (R'R)^{-1}, det(Sigma) = det((R'R)^{-1}) = det(R'R)^{-1}
// log det(Sigma) = -log(det(R'R)) = -2*log(det(R))
// Hence, log det(Sigma)) = - 2.0 * logDeterminant()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

take this comment all the way :-)

@varunagrawal varunagrawal marked this pull request as ready for review January 3, 2024 21:22
Copy link
Member

@dellaert dellaert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few small comments, mostly around naming convention and naming. Would like to run through math with you before merging.

DiscreteFactorGraph discrete_fg;

// Compute model selection term
AlgebraicDecisionTree<Key> model_selection_term = model_selection();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naming convention on variables. modelSelectionTerms? This is a global comment on this PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

This can be computed by multiplying all the exponentiated errors
of each of the conditionals.
*/
AlgebraicDecisionTree<Key> model_selection() const;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naming convention: modelSelection. Although, it's a bit of a weird name, and the comment does not help much. What is the return value?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Hopefully the improved docstring is better.

@varunagrawal varunagrawal force-pushed the model-selection-integration branch from d552eef to 538871a Compare June 27, 2024 00:00
@varunagrawal varunagrawal requested a review from dellaert July 10, 2024 22:26
@varunagrawal
Copy link
Collaborator Author

@dellaert I want to see what can I do to land this ASAP. My thesis document has the latest updates describing these changes (section 7.5.6).

@varunagrawal varunagrawal changed the title Model Selection for Hybrid Estimation Working Hybrid Estimation Aug 20, 2024
@varunagrawal varunagrawal changed the title Working Hybrid Estimation AlgebraicDecisionTree Helpers Aug 20, 2024
@@ -196,6 +196,42 @@ namespace gtsam {
return this->apply(g, &Ring::div);
}

/// Compute sum of all values
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unit tests?

Copy link
Member

@dellaert dellaert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice and small now but please add tests on ADT methods. You can re-use an example tree by putting it in a namespace maybe.

@varunagrawal varunagrawal merged commit 231d1ad into develop Aug 21, 2024
31 checks passed
@varunagrawal varunagrawal deleted the model-selection-integration branch August 21, 2024 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants