def test_zmatrix_reorder(): assignments = [ [2, 345, 2, 2], [3, 345, 2, 2], [3, 9, 1, 1], ] zmat = query.zmatrix(assignments) reordered = query.zmatrix_reorder(zmat, np.arange(zmat.shape[0])) assert_almost_equals(np.abs(zmat - reordered).max(), 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)')