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

markdown for graphs #987

Merged
merged 4 commits into from
Dec 25, 2021
Merged

markdown for graphs #987

merged 4 commits into from
Dec 25, 2021

Conversation

dellaert
Copy link
Member

Added markdown support for all discrete graphs:

  • Bayes net
  • FactorGraph
  • Bayes tree

Needed some changes in DiscreteConditional as well, as root cliques in a Bayes tree can be very large. Hence, I decided to render parent-less conditionals as a vertical table, rather than the more complicated "horizontal" table.

Example from DiscreteSwitching.ipynb:

DiscreteBayesTree of size 9

$P(s4,s5,m1,m2,m3,m4)$:

s4 s5 m1 m2 m3 m4 value
0 0 0 0 0 0 0.01875
0 0 0 0 0 1 0.00208333
0 0 0 0 1 0 0.01875
0 0 0 0 1 1 0.00208333
0 0 0 1 0 0 0.01875
0 0 0 1 0 1 0.00208333
0 0 0 1 1 0 0.01875
0 0 0 1 1 1 0.00208333
0 0 1 0 0 0 0.01875
0 0 1 0 0 1 0.00208333
0 0 1 0 1 0 0.01875
0 0 1 0 1 1 0.00208333
0 0 1 1 0 0 0.01875
0 0 1 1 0 1 0.00208333
0 0 1 1 1 0 0.01875
0 0 1 1 1 1 0.00208333
0 1 0 0 0 0 0.00208333
0 1 0 0 0 1 0.01875
0 1 0 0 1 0 0.00208333
0 1 0 0 1 1 0.01875
0 1 0 1 0 0 0.00208333
0 1 0 1 0 1 0.01875
0 1 0 1 1 0 0.00208333
0 1 0 1 1 1 0.01875
0 1 1 0 0 0 0.00208333
0 1 1 0 0 1 0.01875
0 1 1 0 1 0 0.00208333
0 1 1 0 1 1 0.01875
0 1 1 1 0 0 0.00208333
0 1 1 1 0 1 0.01875
0 1 1 1 1 0 0.00208333
0 1 1 1 1 1 0.01875
0 2 0 0 0 0 0
0 2 0 0 0 1 0
0 2 0 0 1 0 0
0 2 0 0 1 1 0
0 2 0 1 0 0 0
0 2 0 1 0 1 0
0 2 0 1 1 0 0
0 2 0 1 1 1 0
0 2 1 0 0 0 0
0 2 1 0 0 1 0
0 2 1 0 1 0 0
0 2 1 0 1 1 0
0 2 1 1 0 0 0
0 2 1 1 0 1 0
0 2 1 1 1 0 0
0 2 1 1 1 1 0
1 0 0 0 0 0 0.00208333
1 0 0 0 0 1 0
1 0 0 0 1 0 0.00208333
1 0 0 0 1 1 0
1 0 0 1 0 0 0.00208333
1 0 0 1 0 1 0
1 0 0 1 1 0 0.00208333
1 0 0 1 1 1 0
1 0 1 0 0 0 0.00208333
1 0 1 0 0 1 0
1 0 1 0 1 0 0.00208333
1 0 1 0 1 1 0
1 0 1 1 0 0 0.00208333
1 0 1 1 0 1 0
1 0 1 1 1 0 0.00208333
1 0 1 1 1 1 0
1 1 0 0 0 0 0.0166667
1 1 0 0 0 1 0.00208333
1 1 0 0 1 0 0.0166667
1 1 0 0 1 1 0.00208333
1 1 0 1 0 0 0.0166667
1 1 0 1 0 1 0.00208333
1 1 0 1 1 0 0.0166667
1 1 0 1 1 1 0.00208333
1 1 1 0 0 0 0.0166667
1 1 1 0 0 1 0.00208333
1 1 1 0 1 0 0.0166667
1 1 1 0 1 1 0.00208333
1 1 1 1 0 0 0.0166667
1 1 1 1 0 1 0.00208333
1 1 1 1 1 0 0.0166667
1 1 1 1 1 1 0.00208333
1 2 0 0 0 0 0.00208333
1 2 0 0 0 1 0.01875
1 2 0 0 1 0 0.00208333
1 2 0 0 1 1 0.01875
1 2 0 1 0 0 0.00208333
1 2 0 1 0 1 0.01875
1 2 0 1 1 0 0.00208333
1 2 0 1 1 1 0.01875
1 2 1 0 0 0 0.00208333
1 2 1 0 0 1 0.01875
1 2 1 0 1 0 0.00208333
1 2 1 0 1 1 0.01875
1 2 1 1 0 0 0.00208333
1 2 1 1 0 1 0.01875
1 2 1 1 1 0 0.00208333
1 2 1 1 1 1 0.01875
2 0 0 0 0 0 0
2 0 0 0 0 1 0.01875
2 0 0 0 1 0 0
2 0 0 0 1 1 0.01875
2 0 0 1 0 0 0
2 0 0 1 0 1 0.01875
2 0 0 1 1 0 0
2 0 0 1 1 1 0.01875
2 0 1 0 0 0 0
2 0 1 0 0 1 0.01875
2 0 1 0 1 0 0
2 0 1 0 1 1 0.01875
2 0 1 1 0 0 0
2 0 1 1 0 1 0.01875
2 0 1 1 1 0 0
2 0 1 1 1 1 0.01875
2 1 0 0 0 0 0.00208333
2 1 0 0 0 1 0
2 1 0 0 1 0 0.00208333
2 1 0 0 1 1 0
2 1 0 1 0 0 0.00208333
2 1 0 1 0 1 0
2 1 0 1 1 0 0.00208333
2 1 0 1 1 1 0
2 1 1 0 0 0 0.00208333
2 1 1 0 0 1 0
2 1 1 0 1 0 0.00208333
2 1 1 0 1 1 0
2 1 1 1 0 0 0.00208333
2 1 1 1 0 1 0
2 1 1 1 1 0 0.00208333
2 1 1 1 1 1 0
2 2 0 0 0 0 0.01875
2 2 0 0 0 1 0.00208333
2 2 0 0 1 0 0.01875
2 2 0 0 1 1 0.00208333
2 2 0 1 0 0 0.01875
2 2 0 1 0 1 0.00208333
2 2 0 1 1 0 0.01875
2 2 0 1 1 1 0.00208333
2 2 1 0 0 0 0.01875
2 2 1 0 0 1 0.00208333
2 2 1 0 1 0 0.01875
2 2 1 0 1 1 0.00208333
2 2 1 1 0 0 0.01875
2 2 1 1 0 1 0.00208333
2 2 1 1 1 0 0.01875
2 2 1 1 1 1 0.00208333

$P(s3|m1,m2,m3,s4)$:

m1 m2 m3 s4 0 1 2
0 0 0 0 0.9 0.1 0
0 0 0 1 0.1 0.8 0.1
0 0 0 2 0 0.1 0.9
0 0 1 0 0.1 0 0.9
0 0 1 1 0.9 0.1 0
0 0 1 2 0 0.9 0.1
0 1 0 0 0.9 0.1 0
0 1 0 1 0.1 0.8 0.1
0 1 0 2 0 0.1 0.9
0 1 1 0 0.1 0 0.9
0 1 1 1 0.9 0.1 0
0 1 1 2 0 0.9 0.1
1 0 0 0 0.9 0.1 0
1 0 0 1 0.1 0.8 0.1
1 0 0 2 0 0.1 0.9
1 0 1 0 0.1 0 0.9
1 0 1 1 0.9 0.1 0
1 0 1 2 0 0.9 0.1
1 1 0 0 0.9 0.1 0
1 1 0 1 0.1 0.8 0.1
1 1 0 2 0 0.1 0.9
1 1 1 0 0.1 0 0.9
1 1 1 1 0.9 0.1 0
1 1 1 2 0 0.9 0.1

$P(s2|m1,m2,s3)$:

m1 m2 s3 0 1 2
0 0 0 0.9 0.1 0
0 0 1 0.1 0.8 0.1
0 0 2 0 0.1 0.9
0 1 0 0.1 0 0.9
0 1 1 0.9 0.1 0
0 1 2 0 0.9 0.1
1 0 0 0.9 0.1 0
1 0 1 0.1 0.8 0.1
1 0 2 0 0.1 0.9
1 1 0 0.1 0 0.9
1 1 1 0.9 0.1 0
1 1 2 0 0.9 0.1

$P(s1|m1,s2)$:

m1 s2 0 1 2
0 0 0.9 0.1 0
0 1 0.1 0.8 0.1
0 2 0 0.1 0.9
1 0 0.1 0 0.9
1 1 0.9 0.1 0
1 2 0 0.9 0.1

@dellaert dellaert added feature New proposed feature quick-review Quick and easy PR to review wrapper Related to the wrapper labels Dec 24, 2021
Copy link
Collaborator

@varunagrawal varunagrawal left a comment

Choose a reason for hiding this comment

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

LGTM

@varunagrawal varunagrawal merged commit a4f1cf3 into feature/markdown Dec 25, 2021
@varunagrawal varunagrawal deleted the feature/markdown2 branch December 25, 2021 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New proposed feature quick-review Quick and easy PR to review wrapper Related to the wrapper
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants