print("Finish ploting")
    return


#===================================================
df = pd.read_excel('InvestEvent_1.xlsx')
traindata, testdata, _, investors, investors7 = dictify(df)
'''
# sample
train_bipartite = build_graph(traindata)
train_graph = tao_one_mode_projection(train_bipartite, investors)

test_bipartite = build_graph(testdata)
test_graph = tao_one_mode_projection(test_bipartite, investors7)
'''

# sever
train_bipartite = cache_res("company.bipartite.train", build_graph, traindata)
train_graph = cache_res('company.projected.train', tao_one_mode_projection,
                        train_bipartite, investors)

test_bipartite = cache_res('company.bipartite.test', build_graph, testdata)
test_graph = cache_res('company.projected.test', tao_one_mode_projection,
                       test_bipartite, investors7)

VC_predict = investors & investors7

score, true_value = calculate_sim_for_specified_pairs(train_graph, test_graph,
                                                      VC_predict)
roc_plot(score, true_value)
Ejemplo n.º 2
0

def sim(G, u, v):
    common_neighbors = set(G.adj[u]).intersection(G.adj[v])
    assert(all(u in G.adj[w] for w in common_neighbors))
    assert(all(v in G.adj[w] for w in common_neighbors))
    return sum(1 / math.log(G.degree[w], 2) for w in common_neighbors)

def 

=========================================================
df = pd.read_excel('InvestEvent_1.xlsx')
dataX, dataY,  _, investors = dictify(df)

# filename开头用company的含义?
X_bipartite = cache_res("company.bipartite.X", build_graph, dataX)
X_graph = cache_res('company.projected.X', tao_one_mode_projection, X_bipartite, investors)

Y_bipartite = cache_res('company.bipartite.test', build_graph, dataY)
Y_graph = cache_res('company.projected.test', tao_one_mode_projection, Y_bipartite, investors)

X_set = array.array('d')
Y_set = array.array('d')

# 后面可以再算一下(u,v)存在连边和不存在的区别
for u in X_graph.nodes():
    for v in X_graph.nodes():
        if u == v : continue
        X_set.append(sim(X_graph, u, v))

for u in Y_graph.nodes():