Skip to content

Conversation

@albertpod
Copy link
Member

@albertpod albertpod commented Jul 20, 2022

This PR addresses issue #120.

Thanks to @Chengfeng-Jia and @Sepideh-Adamiat for deriving rules.

@albertpod
Copy link
Member Author

This PR misses a nice demo demonstrating these functions' applicability.

Once the demo is finished, we can promote this PR.

Copy link
Member

@bartvanerp bartvanerp left a comment

Choose a reason for hiding this comment

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

First draft of the PR looks good! There are some style issues that need to be tackled and some technical parts, such as:

  • It would be cool if all these operations could have type aliases, such as AND -> & according to the normal Julia syntax. Not sure how elaborate the required changes will be, but in my opinion required before merging.
  • The NOT node now has interfaces out and in1. This latter one implies that there is another input. I would recommend renaming it to in (and also in the tests/rules).
  • In some cases I can image users wanting to use these rules with data variables, I would recommend adding additional rules for Pointmass distributions.
  • I think we need to extend the Contingency object to include normalization and labels.
  • I would like to double check the derivations towards the inputs of the AND and OR node on the whiteboard as these are quite tricky and as I ended up with different results.
  • I did not check the Implication node as I am not sure what it does.


struct IMPL end

@node IMPL Deterministic [out, in1, in2]
Copy link
Member

Choose a reason for hiding this comment

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

What is an implication node? As a user I would not know what it does so it either requires: 1) docstrings/documentation or 2) a name change.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think @bartvanerp's comment is critical and should be addressed. A possible fix would include the truth tables for all logical operations.

Copy link
Member Author

Choose a reason for hiding this comment

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

Perhaps good to add docstrings for every node. The implication is as "famous" as OR or AND operators.

Copy link
Member

Choose a reason for hiding this comment

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

Ah I see that is quite common apparently. Could we use the abbreviation IMPLY instead according to https://en.wikipedia.org/wiki/Logical_connective?

Copy link
Member Author

Choose a reason for hiding this comment

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

@Chengfeng-Jia, what is your opinion on renaming the node?

Copy link
Member

Choose a reason for hiding this comment

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

I think IMPLY may be a proper name. Besides, if we decide to use & instead of AND, can we use $\rightarrow$ to represent Implication.

Copy link
Member

Choose a reason for hiding this comment

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

For the Pointmass part, thanks for @bartvanerp explain. I wonder if Pointmass can be regarded as a special case of Bernoulli distribution. For example, $x=1$ means $\mathcal{B}er\left(x \bigg| 1\right)$.

Copy link

@ThijsvdLaar ThijsvdLaar left a comment

Choose a reason for hiding this comment

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

Amazing effort, I agree with the comments by @bartvanerp Most importantly, the Contingency should indeed be normalized, since it represents a joint distribution over connected variables. It agree that it would be nice to write out the derivations in full, for checking, later reference, and most importantly, it can make for an impressive appendix in your thesis.

@bvdmitri
Copy link
Member

We need to add some sort of example to the documentation Examples section (and demo/ folder). It not only shows how to use these new nodes, but also serves as an extra test because CI fails if some example from the documentation does not run properly.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@albertpod
Copy link
Member Author

albertpod commented Aug 1, 2022

@bartvanerp @bvdmitri @Chengfeng-Jia I've added the demo demonstrating the usage of these nodes.

@codecov-commenter
Copy link

codecov-commenter commented Aug 1, 2022

Codecov Report

Merging #170 (08d406d) into master (0e1efd8) will increase coverage by 0.08%.
The diff coverage is 100.00%.

❗ Current head 08d406d differs from pull request most recent head 1ef5b94. Consider uploading reports for the commit 1ef5b94 to get more accurate results

@@            Coverage Diff             @@
##           master     #170      +/-   ##
==========================================
+ Coverage   76.67%   76.76%   +0.08%     
==========================================
  Files         183      196      +13     
  Lines        6569     6594      +25     
==========================================
+ Hits         5037     5062      +25     
  Misses       1532     1532              
Impacted Files Coverage Δ
src/ReactiveMP.jl 66.66% <ø> (ø)
src/distributions/contingency.jl 100.00% <100.00%> (ø)
src/rules/and/in1.jl 100.00% <100.00%> (ø)
src/rules/and/in2.jl 100.00% <100.00%> (ø)
src/rules/and/marginals.jl 100.00% <100.00%> (ø)
src/rules/and/out.jl 100.00% <100.00%> (ø)
src/rules/implication/in1.jl 100.00% <100.00%> (ø)
src/rules/implication/in2.jl 100.00% <100.00%> (ø)
src/rules/implication/marginals.jl 100.00% <100.00%> (ø)
src/rules/implication/out.jl 100.00% <100.00%> (ø)
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0e1efd8...1ef5b94. Read the comment docs.

@bvdmitri
Copy link
Member

bvdmitri commented Aug 2, 2022

Thanks @albertpod , @Chengfeng-Jia and @Sepideh-Adamiat . I'm fine with the current state of the PR. Once tests are passed we can merge.

@bartvanerp
Copy link
Member

After adding docstrings with truth tables I think this PR should be ready for merge

@albertpod albertpod marked this pull request as ready for review August 4, 2022 16:15
Copy link
Member

@bvdmitri bvdmitri left a comment

Choose a reason for hiding this comment

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

Great work @albertpod , @Chengfeng-Jia and @Sepideh-Adamiat ! That is very good addition to our framework.

@@ -0,0 +1,20 @@
module OrNodeTest
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
module OrNodeTest
module ImplicationNodeTest

src/nodes/not.jl Outdated

struct NOT end

@node NOT Deterministic [out, in1]
Copy link
Member

Choose a reason for hiding this comment

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

Tests fail because they expect to see :in :)

Suggested change
@node NOT Deterministic [out, in1]
@node NOT Deterministic [out, in]

This change also requires to fix all rules from :in1 to :in

@bvdmitri bvdmitri merged commit 93f555e into master Aug 5, 2022
@bvdmitri bvdmitri deleted the dev_logic branch August 5, 2022 11:53
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.

8 participants