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

Fix incorrect probabilities and typos

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