Revision 36331ad0 timeAnalysis.py
timeAnalysis.py  

1 
import seaborn as sns 

1  2 
import code # code.interact(local=dict(globals(), **locals())) 
2  3 
from collections import deque 
3  4 
from scipy import stats 
...  ...  
5  6 
from collections import defaultdict 
6  7 
import os 
7  8 
import sys 
8 
from statsmodels.graphics.tsaplots import plot_acf, acf 

9 
from statsmodels.graphics.tsaplots import plot_acf 

10 
from statsmodels.tsa.stattools import acf 

9  11 
import operator 
10  12 
from mpl_toolkits import mplot3d 
11  13 
import pandas as pd 
12  14 
from pprint import pprint 
13  15 
import numpy as np 
14  16 
import glob 
17 
from tqdm import tqdm 

15  18 
import matplotlib 
16  19  
17  
20 
#mys.rank(method='first', ascending=False) 

18  21  
19  22 
folder = sys.argv[1] 
20  23 
lags = 100 
...  ...  
37  40  
38  41 
nodes = range(len(bcdf.columns)) 
39  42  
40 
initialCentrality = {} 

43 
'''initialCentrality = {}


41  44 
for n in nodes: 
42  45 
initialCentrality[int(n)] = bcdf.iloc[0][n] 
43  46  
44  47  
45  48 
sorted_x = sorted(initialCentrality.items(), 
46  49 
key=operator.itemgetter(1), reverse=True) 
47 
srtNodes = [e[0] for e in sorted_x] 

50 
srtNodes = [e[0] for e in sorted_x]'''


48  51  
49  52 
bcACF = pd.DataFrame() # rows=TimeLags, columns = nodes 
50  53 
degACF = pd.DataFrame() # rows=TimeLags, columns = nodes 
...  ...  
74  77 
os.chdir("plots"+nick) 
75  78 
# Plotting 
76  79  
77  
78  80 
# ACF boxplots 
79 
bcACF.T.boxplot(column=[1]+range(5,lags,5))


81 
bcACF.T.boxplot(column=[1]+range(5, lags, 5))


80  82 
plt.ylabel("ACF of BC for all nodes") 
81  83 
plt.xlabel("Timelag") 
82  84 
plt.xticks(rotation="vertical") 
...  ...  
88  90 
plt.savefig(nick+"autoCorrBOXPLOTBC.pdf", format='pdf') 
89  91 
plt.clf() 
90  92  
91 
degACF.T.boxplot(column=[1]+range(5,lags,5))


93 
degACF.T.boxplot(column=[1]+range(5, lags, 5))


92  94 
plt.ylabel("ACF of DEG for all nodes") 
93  95 
plt.xlabel("Timelag") 
94  96 
plt.xticks(rotation="vertical") 
...  ...  
100  102 
plt.savefig(nick+"autoCorrBOXPLOTDEG.pdf", format='pdf') 
101  103 
plt.clf() 
102  104  
103 
kcoreACF.T.boxplot(column=[1]+range(5,lags,5))


105 
kcoreACF.T.boxplot(column=[1]+range(5, lags, 5))


104  106 
plt.ylabel("ACF of KCORE for all nodes") 
105  107 
plt.xlabel("Timelag") 
106  108 
plt.xticks(rotation="vertical") 
...  ...  
113  115 
plt.clf() 
114  116  
115  117  
116  
117  118 
# Mean AutoCorrelation and RankCorrelation 
118  119 
# lags=20 
119  120 
firstRank = bcdf.iloc[0, :] 
...  ...  
174  175 
[b, c, 1]]) 
175  176  
176  177 
#code.interact(local=dict(globals(), **locals())) 
177 
import seaborn as sns 

178  178 
sns.set() 
179  179  
180  180 
Also available in: Unified diff