-
Notifications
You must be signed in to change notification settings - Fork 0
/
granger_explore.py
46 lines (35 loc) · 1.13 KB
/
granger_explore.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import matplotlib.pyplot as plt
import numpy as np
import networkx as nx
import pandas as pd
# Load Granger matrix
data_m=np.load('granger_01month.npy')
# Thresholding
thres=40
data_m[data_m<thres]=0
data_m[data_m>=thres]=1
plt.spy(data_m)
plt.show()
# Making the graph, and also printed the properties
G = nx.Graph(data_m)
degrees_list=np.zeros((len(data_m),1))
for ii in range(len(degrees_list)):
degrees_list[ii] = G.degree([ii])[ii]
plt.hist(degrees_list);
plt.show()
cc = nx.number_connected_components(G)
ac = nx.average_clustering(G)
print(f"Number of connected components: {cc}")
print(f"Average clustering coefficient: {ac}")
# Loading the google citation data
data_goo=pd.read_csv('citations.txt',delimiter='\t')
researcher_idx = data_goo['id'].values
researcher_hidx = data_goo['h_index'].values
# Getting the data point of top 50 degrees
degree_high = np.argsort(degrees_list[:,0])[-50:]
c=np.load('granger_indexes.npy')
hidex=[]
for ii in degree_high:
hidex.append(researcher_hidx[np.where(researcher_idx==c[ii])])
print(researcher_hidx.mean())
print(np.array(hidex).mean())