Value error in Gibs sampling : Variable names cannot be same #1591
Alextenz
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
from pgmpy.models import BayesianNetwork
from pgmpy.factors.discrete import TabularCPD
from pgmpy.sampling import GibbsSampling
Catch = BayesianNetwork([('B','A'),('E','A'),('A','J'),('A','M')])
burg_cpd = TabularCPD('B',2, values = [[0.999],[0.001]])
print(burg_cpd)
earth_cpd = TabularCPD('E',2, values = [[0.998],[0.002]])
print(earth_cpd)
alarm_cpd = TabularCPD('A', 2, values = [[0.999,0.71,0.06,0.05],
[0.001,0.29,0.94,0.95]],
evidence=['B','E'],evidence_card=[2,2])
print(alarm_cpd)
merry_cpd = TabularCPD('M',2, values = [
[0.99,0.3],[0.01,0.7]],
evidence=['A'],evidence_card=[2])
print(merry_cpd)
john_cpd = TabularCPD('J',2, values = [
[0.95,0.1],[0.05,0.9]],
evidence=['A'],evidence_card=[2])
print(john_cpd)
Catch.add_cpds(merry_cpd,john_cpd,alarm_cpd,earth_cpd,burg_cpd)
Catch.nodes()
gibbs_chain = GibbsSampling(Catch)
gibbs_chain.sample(size=300)
Beta Was this translation helpful? Give feedback.
All reactions