-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathInitial.py
More file actions
30 lines (25 loc) · 814 Bytes
/
Initial.py
File metadata and controls
30 lines (25 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/python
#-*-coding:utf-8-*-
'''@author:duncan'''
import Metric as metric
import numpy as np
import pandas as pd
import pickle
import networkx as nx
# 初始化代表性矩阵
def Init(category):
print "加载数据"
feature = ['followers','friends','statuses','favourites','activity','influence','location','verified']
id_list_path = "%s_ids" % category
rels_path = "%s_rels" % category
users = pd.read_csv(category+"Users.csv")
R = np.load("%sRepresentativeMatrix.npy" % category)
ids_file = open(id_list_path,'rb')
id_list = pickle.load(ids_file)
rel_file = open(rels_path,'rb')
rels = pickle.load(rel_file)
g = nx.Graph()
g.add_edges_from(rels)
print "数据加载完毕"
return feature,users,R,id_list,g
# InitialMatrix(datapre.Features())