def propagate_evidence(theme, bn, possible_evidence, features, file_name, start, threhshold, nodes): combinations_possible_evidence = create_combinations_evidence(possible_evidence, start) for x in combinations_possible_evidence: evidences = create_evidence_from_list(x) for evidence in evidences: try: inf = inference(bn, evidence) inf = likelihood_from_inference(inf) # print inf accuracy = inference_accuracy(dataset, nodes, features, inf, threhshold) save_evidence(file_name, accuracy, evidence, len(x)) print accuracy except Exception: print 'Exception ' + str(evidence)
def propagate_evidence(bn, possible_evidence, features, file_name, start, threhshold, nodes): combinations_possible_evidence = create_combinations_evidence(possible_evidence, start) for x in combinations_possible_evidence: # convert to string for join tree evidences = create_evidence_from_list(x) evidences = map(convert_values_to_string, evidences) for evidence in evidences: try: inf = jt_inference(bn, evidence) inf = likelihood_from_inference(inf) # print inf accuracy = inference_accuracy(dataset, nodes, features, inf, threhshold) save_evidence(file_name, accuracy, evidence, len(x)) print accuracy except Exception: print 'Exception ' + str(evidence)