Example #1
0
def test_zmatrix_heuristic_block_reordering():
    assignments = [
        [2, 345, 2, 2],
        [3, 345, 2, 2],
        [3, 9, 1, 1],
    ]
    zmat = query.zmatrix(assignments)
    order = query.zmatrix_heuristic_block_ordering(zmat)
    assert_true(query._is_permutation(order, zmat.shape[0]))
Example #2
0
def get_full_name(name):
    return enron_utils.FULLNAMES.get(name, name)
def get_title(name):
    return enron_utils.TITLES.get(name, "?")

for cluster, payload in suspicious.values():
    cnames = cluster_names(cluster)
    ctitles = map(get_title, cnames)
    print payload["desc"]
    for n, t in zip(cnames, ctitles):
        print "\t", get_full_name(n), '\t\t"{}"'.format(t)
    print


# #Given the uncertainty behind these latent clusters, we can visualize the variablity within these assignments with a z-matrix
# 
# ###Ordering the z-matrix allows us to group members of each possible cluster together

# In[ ]:

zmat = query.zmatrix(domain=0, latents=infers)
zmat = zmatrix_reorder(zmat, zmatrix_heuristic_block_ordering(zmat))


# In[ ]:

plt.imshow(zmat, cmap=plt.cm.binary, interpolation='nearest')
plt.xlabel('people (sorted)')
plt.ylabel('people (sorted)')