示例#1
0
def main(data_set_name):
    dimensions = 4
    input_file = './graph/' + data_set_name + '.tsv'
    output_file = './emb/' + data_set_name + '.emb'
    # Instatiate the embedding method with hyperparameters
    sdne = SDNE(dimensions)

    # Load graph
    graph = graph_util.loadGraphFromEdgeListTxt(input_file)

    # Learn embedding - accepts a networkx graph or file with edge list
    embeddings_array, t = sdne.learn_embedding(graph,
                                               edge_f=None,
                                               is_weighted=True,
                                               no_python=True)
    embeddings = pandas.DataFrame(embeddings_array)
    embeddings.to_csv(output_file, sep=' ', na_rep=0.1)
示例#2
0
                 nu2=1e-6,
                 K=3,
                 n_units=[
                     50,
                     15,
                 ],
                 rho=0.3,
                 n_iter=50,
                 xeta=0.01,
                 n_batch=500,
                 modelfile=[
                     './outdata/intermediate/enc_model.json',
                     './outdata/intermediate/dec_model.json'
                 ],
                 weightfile=[
                     './outdata/intermediate/enc_weights.hdf5',
                     './outdata/intermediate/dec_weights.hdf5'
                 ])

# Learn embedding - accepts a networkx graph or file with edge list
Y, t = embedding.learn_embedding(graph=G, is_weighted=True)

# ev.evaluateNodeClassification()
# print(Y)

viz.plot_embedding2D(embedding.get_embedding(), di_graph=G, node_colors=None)
plt.show()
# print(Y)
# # Evaluate on graph reconstruction
# MAP, prec_curv, err, err_baseline = gr.evaluateStaticGraphReconstruction(G, embedding, Y, None)