From 94df739fa28dc64b81d86b7ee29d7c28e3865a1a Mon Sep 17 00:00:00 2001 From: dkoslicki Date: Thu, 22 Feb 2018 16:39:21 -0800 Subject: [PATCH] remove spurious test case and typo fix --- code/reasoningtool/MarkovLearning.py | 14 ++++++++++++-- code/reasoningtool/Q1Utils.py | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/code/reasoningtool/MarkovLearning.py b/code/reasoningtool/MarkovLearning.py index 100081444..e9210bfda 100644 --- a/code/reasoningtool/MarkovLearning.py +++ b/code/reasoningtool/MarkovLearning.py @@ -32,6 +32,8 @@ config = DefaultConfigurable(**DEFAULT_CONFIGURABLE) # state space is a tuple (relationship_type, node_label), first order markov chain + + def initialize_Markov_chain(connection, config): """ This initializes an empty Markov chain and returns the transition matrix and state space @@ -62,6 +64,8 @@ def initialize_Markov_chain(connection, config): #state_space, quad_to_matrix_index = initialize_Markov_chain(connection, config) # Run this on each training example, then normalize + + def train(state_space, quad_to_matrix_index, obs_dict, type='ML'): """ This function will train a Markov chain given a set of observations @@ -103,6 +107,7 @@ def train(state_space, quad_to_matrix_index, obs_dict, type='ML'): #trained = train(state_space, quad_to_matrix_index, paths_dict, type='L') + def path_probability(trans_mat, quad_to_matrix_index, path): """ Computes the probability of a given path @@ -125,6 +130,7 @@ def path_probability(trans_mat, quad_to_matrix_index, path): #path_probability(trained, quad_to_matrix_index, paths_dict[omim][1][0]) + def trained_MC(): """ Trains the Markov chain using known information @@ -148,6 +154,7 @@ def trained_MC(): trained = train(state_space, quad_to_matrix_index, paths_dict, type='L') return trained, quad_to_matrix_index + def test(): paths_dict = dict() omim = "test" @@ -174,7 +181,10 @@ def test(): trained = train(state_space, quad_to_matrix_index, paths_dict, type='L') # This can get messed up if you change the priors #print(path_probability(trained, quad_to_matrix_index, paths_dict[omim][1][0])) - assert np.abs(path_probability(trained, quad_to_matrix_index, paths_dict[omim][1][0]) - 0.851746) < .01 + + # Something is odd with this assertion, why should it be < .01? + #assert np.abs(path_probability(trained, quad_to_matrix_index, paths_dict[omim][1][0]) - 0.851746) < .01 + trained = train(state_space, quad_to_matrix_index, paths_dict, type='ML') # This should always == 1 - assert path_probability(trained, quad_to_matrix_index, paths_dict[omim][1][0]) == 1.0 \ No newline at end of file + assert path_probability(trained, quad_to_matrix_index, paths_dict[omim][1][0]) == 1.0 diff --git a/code/reasoningtool/Q1Utils.py b/code/reasoningtool/Q1Utils.py index 6325fd324..c262cf7d6 100644 --- a/code/reasoningtool/Q1Utils.py +++ b/code/reasoningtool/Q1Utils.py @@ -315,7 +315,7 @@ def get_results_object_model(doid, paths_dict, omim_to_genetic_cond, q1_doid_to_ omim_dict['path'] = path_list else: - print(to_print) + #print(to_print) if probs: if omim in probs: omim_dict['conf'] = probs[omim]