def test_lhn_sim(self): G = self.G lhn_sim, nodelist = lhn(G) nt.assert_equal(len(nodelist), 6) for i in range(6): nt.assert_true(i in nodelist) nt.assert_equal(len(lhn_sim), 6) for i in range(self.G.lhn_sim.shape[0]): for j in range(self.G.lhn_sim.shape[1]): print i, ',', j nt.assert_almost_equal(self.G.lhn_sim[i,j], lhn_sim[i,j], places=4)
def test_lhn_sim(self): G = self.G lhn_sim, nodelist = lhn(G) nt.assert_equal(len(nodelist), 6) for i in range(6): nt.assert_true(i in nodelist) nt.assert_equal(len(lhn_sim), 6) for i in range(self.G.lhn_sim.shape[0]): for j in range(self.G.lhn_sim.shape[1]): print i, ',', j nt.assert_almost_equal(self.G.lhn_sim[i, j], lhn_sim[i, j], places=4)
graphs = pickle.load(open('data/graphs_networkx.pkl', 'rb')) results = dict() for graph_type, G in graphs.iteritems(): print "Calculating for %s" % (graph_type) results[graph_type] = dict() print "ASCOS ---------------------------" results[graph_type]["ascos"] = ascos(G) print "COSINE ---------------------------" results[graph_type]["cosine"] = cosine(G) print "JACCARD --------------------------" results[graph_type]["jaccard"] = jaccard(G) print "KATZ -----------------------------" results[graph_type]["katz"] = katz(G) print "LHN ------------------------------" results[graph_type]["lhn"] = lhn(G) print "RSS2 -----------------------------" results[graph_type]["rss2"] = rss2(G) print "DICE -----------------------------" results[graph_type]["dice"] = dice(G) print "INVERSE LOG WEIGHTED --------------" results[graph_type]["inverse_log_weighted"] = inverse_log_weighted(G) pickle.dump(results, open("data/sim_metrics.pkl", "wb")) ### IMAGE SIMILARITY # Let's make a concept by concept data frame contrast_lookup = pandas.read_csv("data/contrast_by_concept_binary_df.tsv", sep="\t", index_col=0)
graphs = pickle.load(open('data/graphs_networkx.pkl','rb')) results = dict() for graph_type,G in graphs.iteritems(): print "Calculating for %s" %(graph_type) results[graph_type] = dict() print "ASCOS ---------------------------" results[graph_type]["ascos"] = ascos(G) print "COSINE ---------------------------" results[graph_type]["cosine"] = cosine(G) print "JACCARD --------------------------" results[graph_type]["jaccard"] = jaccard(G) print "KATZ -----------------------------" results[graph_type]["katz"] = katz(G) print "LHN ------------------------------" results[graph_type]["lhn"] = lhn(G) print "RSS2 -----------------------------" results[graph_type]["rss2"] = rss2(G) print "DICE -----------------------------" results[graph_type]["dice"] = dice(G) print "INVERSE LOG WEIGHTED --------------" results[graph_type]["inverse_log_weighted"] = inverse_log_weighted(G) pickle.dump(results,open("data/sim_metrics.pkl","wb")) ### IMAGE SIMILARITY # Let's make a concept by concept data frame contrast_lookup = pandas.read_csv("data/contrast_by_concept_binary_df.tsv",sep="\t",index_col=0) images = pandas.read_csv("data/contrast_defined_images_filtered.tsv",sep="\t",index_col=0)