-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyse.py
64 lines (56 loc) · 1.57 KB
/
analyse.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from pandas import read_csv, concat
from glob import glob
import seaborn as sns
import matplotlib.pyplot as plt
# Loading simulations
simulate_all = 'results/simulate_all/*.csv'
simulate_sequentially = 'results/simulate_sequentially/*.csv'
all_files = glob(simulate_sequentially)
simulations = []
for filename in all_files:
df = read_csv(filename, index_col=0)
simulations.append(df)
simulations = concat(simulations)
# Beautifying labels
simulations.columns = [column.replace("_", " ").title() for column in simulations.columns]
print(simulations.describe())
# Casting columns
for i in range(len(simulations.columns)):
if simulations.dtypes[i] != 'float64' or simulations.dtypes[i] != 'int64':
simulations[simulations.columns[i]] = simulations[simulations.columns[i]].astype(float)
# Calculating correlations
corr = simulations.corr(min_periods=8)
print(corr)
# Creating palette for plots
palette = sns.diverging_palette(220, 20, n=200)
# Pairplot
# sns.pairplot(simulations, palette=palette)
# plt.show()
# Correlation matrix heatmap
ax = sns.heatmap(
corr,
center=0,
cmap=palette,
square=True,
annot=True,
)
ax.set_xticklabels(
ax.get_xticklabels(),
rotation=45,
horizontalalignment='right'
)
ax.set_title('Correlation matrix heatmap')
plt.show()
# Blocking Coefficient correlations bar plot
ax = sns.barplot(
x=corr['Blocking Coefficient'].index,
y=corr['Blocking Coefficient'].values,
palette=palette,
)
ax.set_xticklabels(
ax.get_xticklabels(),
rotation=45,
horizontalalignment='right'
)
ax.set_title('Correlation by Blocking Coefficient')
plt.show()