Skip to content

Commit

Permalink
Fix/message passing typo and docs (#1760)
Browse files Browse the repository at this point in the history
* fix: typo BeliefPropagationWithMessageParsing to BeliefPropagationWithMessagePassing

* fix: add Belief Propagation with Message Passing to docs

* fix: typos where BeliefPropagationWithMessagePassing is called

* fix: len of ===
  • Loading branch information
tillwenke committed May 21, 2024
1 parent 1ac3c21 commit 8975b88
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
2 changes: 2 additions & 0 deletions docs/exact_infer/base.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Exact Inference

- :doc:`ve`
- :doc:`bp`
- :doc:`bp_wmp`
- :doc:`causal`
- :doc:`mplp`
- :doc:`dbn_infer`
Expand All @@ -13,6 +14,7 @@ Exact Inference

ve.rst
bp.rst
bp_wmp.rst
causal.rst
mplp.rst
dbn_infer.rst
5 changes: 5 additions & 0 deletions docs/exact_infer/bp_wmp.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Belief Propagation with Message Passing
========================================

.. autoclass:: pgmpy.inference.ExactInference.BeliefPropagationWithMessagePassing
:members:
6 changes: 3 additions & 3 deletions pgmpy/inference/ExactInference.py
Original file line number Diff line number Diff line change
Expand Up @@ -1238,11 +1238,11 @@ def map_query(
return map_query_results


class BeliefPropagationWithMessageParsing(Inference):
class BeliefPropagationWithMessagePassing(Inference):
"""
Class for performing efficient inference using Belief Propagation method on factor graphs with no loops.
The message-parsing algorithm recursively parses the factor graph to propagate the
The message-passing algorithm recursively parses the factor graph to propagate the
model's beliefs to infer the posterior distribution of the queried variable. The recursion
stops when reaching an observed variable or a unobserved root/leaf variable.
Expand All @@ -1269,7 +1269,7 @@ def __init__(self, model: FactorGraph, check_model=True):

class _RecursiveMessageSchedulingQuery(object):
"""
Private class used in `BeliefPropagationWithMessageParsing.query()` to efficiently
Private class used in `BeliefPropagationWithMessagePassing.query()` to efficiently
manage the message scheduling across the different queried variables, in a recursive way.
Parameters
Expand Down
4 changes: 2 additions & 2 deletions pgmpy/inference/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from .CausalInference import CausalInference
from .ExactInference import BeliefPropagation
from .ExactInference import VariableElimination
from .ExactInference import BeliefPropagationWithMessageParsing
from .ExactInference import BeliefPropagationWithMessagePassing
from .ApproxInference import ApproxInference
from .dbn_inference import DBNInference
from .mplp import Mplp
Expand All @@ -12,7 +12,7 @@
"VariableElimination",
"DBNInference",
"BeliefPropagation",
"BeliefPropagationWithMessageParsing",
"BeliefPropagationWithMessagePassing",
"BayesianModelSampling",
"CausalInference",
"ApproxInference",
Expand Down
6 changes: 3 additions & 3 deletions pgmpy/tests/test_inference/test_ExactInference.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from pgmpy.factors.discrete import DiscreteFactor, TabularCPD
from pgmpy.inference import BeliefPropagation, VariableElimination
from pgmpy.inference.ExactInference import BeliefPropagationWithMessageParsing
from pgmpy.inference.ExactInference import BeliefPropagationWithMessagePassing
from pgmpy.models import BayesianNetwork, FactorGraph, JunctionTree, MarkovNetwork


Expand Down Expand Up @@ -1113,7 +1113,7 @@ def tearDown(self):
del self.bayesian_model


class TestBeliefPropagationWithMessageParsing(unittest.TestCase):
class TestBeliefPropagationWithMessagePassing(unittest.TestCase):
def setUp(self):
self.factor_graph = FactorGraph()
self.factor_graph.add_nodes_from(["A", "B", "C", "D"])
Expand Down Expand Up @@ -1141,7 +1141,7 @@ def setUp(self):
]
)

self.belief_propagation = BeliefPropagationWithMessageParsing(self.factor_graph)
self.belief_propagation = BeliefPropagationWithMessagePassing(self.factor_graph)

def test_query_single_variable(self):
res = self.belief_propagation.query(["C"])
Expand Down

0 comments on commit 8975b88

Please sign in to comment.