Ejemplo n.º 1
0
with open(my_data_path + 'tree_params.pickle', 'rb') as handle:
    params = pickle.load(handle,  encoding='latin1')

with open(my_data_path + 'tree_samples.pickle', 'rb') as handle:
    samples = pickle.load(handle,  encoding='latin1')


"""
    Construct a tree with parameters from the loaded parameter dict.
"""


params_name = list(params.keys())[0]

params = params[list(params.keys())[0]]
root = load_params(params)


"""
    Load a matching sample into the tree.
"""
samples_name = params_name + '_sample_1'
sample = samples[samples_name]
load_sample(root, sample)


print('Root: \n')
print_tree(root, print_sample = True)
betas = find_leaf(root)

Ejemplo n.º 2
0
        root_in_i = s(root, i, prob_dictionary) * root.cat[0][i]
        tot_sum += root_in_i
    return tot_sum


# -- main:

my_data_path = ''  # os.path.dirname(os.path.realpath(__file__)) + '\\'

for i in range(26):  # because we have 27 trees
    with open(my_data_path + 'tree_params.pickle', 'rb') as handle:
        params = pickle.load(handle, encoding='latin1')

    with open(my_data_path + 'tree_samples.pickle', 'rb') as handle:
        samples = pickle.load(handle, encoding='latin1')

    params_name = list(params.keys())[i]
    params = params[params_name]
    root = load_params(params)
    print("Tree #" + str(i + 1))
    for k in range(3):
        """
                    Load a matching sample into the tree.
        """
        samples_name = params_name + '_sample_' + str(
            k + 1)  # load 1-3 samples of each tree
        sample = samples[samples_name]
        load_sample(root, sample)

        print("sample " + str(k + 1) + ": " + str(likelihood(root)))