You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the evidence under the first time slice of D is true and the evidence under the third time slice is false, the probability of the second time slice is calculated by reasoning. The final calculation result is D2, True: 0.7365902, False:0.2634098
Actual behaviour
CPD associated with (B, 1) doesn't have proper parents associated with it. Is this a problem of network model building? Specific network diagram, see [https://www.bilibili.com/video/BV1W3411M7cp/?spm_id_from=333.337.search-card.all.click&vd_source=1a42ddbfb403e da9de41b20ccdca8523]
The text was updated successfully, but these errors were encountered:
@tomorrown I think there is a slight mistake in the CPDs that you have defined. For variables (D, 1) and (B, 1), the evidence variables should be [(B, 0), (C, 1)] and [(A, 1), (B, 0)]. If you fix this, the model definition seems to work for me. The inference still is throwing an error, and I am still looking into it.
Subject of the issue
A Dynamic Bayesian network is built, but the network is always displayed: CPD associated with (B, 1) doesn't have proper parents associated with it.
Your environment
Steps to reproduce
from pgmpy.factors.discrete import TabularCPD
from pgmpy.models import DynamicBayesianNetwork as DBN
from pgmpy.inference import DBNInference
dbnet = DBN()
dbnet.add_edges_from(
[(('A', 0), ('B', 0)), (('A', 0), ('C', 0)),
(('C', 0), ('D', 0)), (('B', 0), ('B', 1)),
(('B', 0), ('D', 1 ))
]
)
a_cpds = TabularCPD(('A', 0), 2, [[0.7], [0.3]])
b_start_cpds = TabularCPD(
('B', 0), 2, [[0.3, 0.6],
[0.7, 0.4]],
evidence=[('A', 0)],
evidence_card=[2]
)
b_trans_cpds = TabularCPD(
('B',1), 2, [[0.1, 0.3, 0.8, 0.6],
[0.9, 0.7, 0.2, 0.4]],
evidence=[('A', 0), ('B', 0)],
evidence_card=[2, 2]
)
c_cpds = TabularCPD(
('C', 0), 2, [[0.3, 0.1],
[0.7,0.9]],
evidence=[('A', 0)],
evidence_card=[2]
)
d_start_cpds = TabularCPD(
('D',0), 2, [[0.4, 0.2], [0.6, 0.8]],
evidence=[('C', 0)],
evidence_card=[2]
)
d_trans_cpds = TabularCPD(
('D',1), 2, [[0.3, 0.4, 0.8, 0.9],
[0.7, 0.6, 0.2, 0.1]],
evidence=[('B', 0),('C',0)],
evidence_card=[2, 2]
)
dbnet.add_cpds(a_cpds, b_start_cpds, b_trans_cpds, c_cpds, d_start_cpds, d_trans_cpds)
dbnet.initialize_initial_state()
dbn_inf = DBNInference(dbnet)
temp = dbn_inf.query([('D', 1)], {('D', 0):0, ('D', 2):1})['D', 1].values
print(temp)
Expected behaviour
When the evidence under the first time slice of D is true and the evidence under the third time slice is false, the probability of the second time slice is calculated by reasoning. The final calculation result is D2, True: 0.7365902, False:0.2634098
Actual behaviour
CPD associated with (B, 1) doesn't have proper parents associated with it. Is this a problem of network model building? Specific network diagram, see [https://www.bilibili.com/video/BV1W3411M7cp/?spm_id_from=333.337.search-card.all.click&vd_source=1a42ddbfb403e da9de41b20ccdca8523]
The text was updated successfully, but these errors were encountered: