Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add MTTM #9064

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,801 changes: 1,801 additions & 0 deletions examples/MTTM/Datasets/DBLP/fakeData.csv

Large diffs are not rendered by default.

1,801 changes: 1,801 additions & 0 deletions examples/MTTM/Datasets/DBLP/realData.csv

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions examples/MTTM/Datasets/DataProcessing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import networkx as nx
import numpy as np
import pandas as pd
from node2vec import Node2Vec
from node2vec.edges import HadamardEmbedder


def get_graph(filepath):
dataGraph = pd.read_csv(filepath, sep=' ', skiprows=0)
graph = nx.Graph()
edges = np.array(dataGraph)
for edge in edges:
print('leftNode:', edge[0], 'rightNode:', edge[1])
graph.add_edge(edge[0], edge[1])
return graph


def get_edge_embeddings(graph, savepath): # node2vec生成边向量表征(64维)
node2vec = Node2Vec(graph, dimensions=64, walk_length=5, num_walks=10,
workers=1)
model = node2vec.fit(window=10, min_count=1, batch_words=1)
edges_embs = HadamardEmbedder(keyed_vectors=model.wv)
edges_kv = edges_embs.as_keyed_vectors()
edges_kv.save_word2vec_format(savepath)


def pro_data_main(dataset):
print("Input dataset:", dataset)
pathReal = './' + dataset + '/realData.csv'
#only real graph to be embedded
#pathFake = 'Data/' + dataset + '/fakeData.csv'
graph = get_graph(pathReal) #real graph
savepath = './node2vecFeature/' + dataset.lower() + 'Feature.txt' # 最终数据
get_edge_embeddings(graph, savepath)


if __name__ == '__main__':
datasets = ['Facebook']
for dataset in datasets:
pro_data_main(dataset)
Loading
Loading