feat: complete q4
This commit is contained in:
parent
1ebc830f2b
commit
6de3e08829
17
inference.py
17
inference.py
@ -201,7 +201,22 @@ def inferenceByVariableEliminationWithCallTracking(callTrackingList=None):
|
|||||||
eliminationOrder = sorted(list(eliminationVariables))
|
eliminationOrder = sorted(list(eliminationVariables))
|
||||||
|
|
||||||
"*** YOUR CODE HERE ***"
|
"*** YOUR CODE HERE ***"
|
||||||
raiseNotDefined()
|
current_factors = bayesNet.getAllCPTsWithEvidence(evidenceDict)
|
||||||
|
print(joinFactorsByVariable)
|
||||||
|
|
||||||
|
for eliminate_var in eliminationOrder:
|
||||||
|
unjoined_factors, joined_factor = joinFactorsByVariable(current_factors, eliminate_var)
|
||||||
|
current_factors = unjoined_factors
|
||||||
|
|
||||||
|
# if the joined_factor's unconditioned variables not only have the eliminate_variable.
|
||||||
|
# we can eliminate this.
|
||||||
|
if len(joined_factor.unconditionedVariables()) > 1:
|
||||||
|
current_factors.append(eliminate(joined_factor, eliminate_var))
|
||||||
|
|
||||||
|
new_factor = joinFactors(current_factors)
|
||||||
|
new_factor = normalize(new_factor)
|
||||||
|
return new_factor
|
||||||
|
|
||||||
"*** END YOUR CODE HERE ***"
|
"*** END YOUR CODE HERE ***"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user