Skip to content
Snippets Groups Projects
Commit 914b0ded authored by Jon's avatar Jon
Browse files

Fix incorrect probabilities and typos

parent d34fc788
Branches
No related tags found
No related merge requests found
......@@ -45,7 +45,7 @@ houses = ['gryffindor', 'ravenclaw', 'slytherin', 'hufflepuff']
for i, prob in enumerate([0.002, 0.002, 0.0001, 0.01]):
pd['PureHeart=true|House={0}'.format(houses[i])] = prob
pd['PureHeart=false|House={0}'.format(houses[i])] = 1 - prob
for i, prob in enumerate([0.05, 0.02, 0.02, 0.001]):
for i, prob in enumerate([0.05, 0.02, 0.02, 0.01]):
pd['Brave=true|House={0}'.format(houses[i])] = prob
pd['Brave=false|House={0}'.format(houses[i])] = 1 - prob
for house in houses:
......
......@@ -61,8 +61,8 @@ brave_cpd = TabularCPD(
evidence=['House'],
evidence_card=[4],
values=[
[0.05, 0.02, 0.02, 0.001], # Brave true
[1 - 0.05, 1 - 0.02, 1 - 0.02, 1 - 0.001] # Brave false
[0.05, 0.02, 0.02, 0.01], # Brave true
[1 - 0.05, 1 - 0.02, 1 - 0.02, 1 - 0.01] # Brave false
]
)
hogwarts_bn.add_cpds(brave_cpd)
......
......@@ -12,10 +12,10 @@ hogwarts_hmm = DenseHMM()
states = ['gryffindor', 'ravenclaw', 'slytherin', 'hufflepuff']
# Possible observations:
# 0. AcromantulaSighting=true, UnicornSighting=true (AU)
# 1. AcromantulaSighting=true, UnicornSighting=false (AX)
# 2. AcromantulaSighting=false, UnicornSighting=true (XU)
# 4. AcromantulaSighting=false, UnicornSighting=false (XX)
# 0. AcromantulaSighting=true, UnicornSighting=true (XX)
# 1. AcromantulaSighting=true, UnicornSighting=false (XO)
# 2. AcromantulaSighting=false, UnicornSighting=true (OX)
# 4. AcromantulaSighting=false, UnicornSighting=false (OO)
# emission probability distributions for the two hidden states
state_dists = [None, None, None, None]
......@@ -24,7 +24,6 @@ for i, house in enumerate(states):
query = inference.query(variables=['AcromantulaSighting','UnicornSighting'], evidence={'House': i, 'TimeOfDay': 1} )
val = query.values
probabilities = [val[0,0], val[0,1], val[1,0], val[1,1]]
print(np.array(probabilities).sum())
cur_state_dist = Categorical([probabilities])
state_dists[i] = cur_state_dist
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment