Skip to content

Commit

Permalink
e5 plot fix
Browse files Browse the repository at this point in the history
  • Loading branch information
JKomorniczak committed Oct 24, 2023
1 parent 9c26d67 commit 6438bfe
Show file tree
Hide file tree
Showing 9 changed files with 143,591 additions and 31 deletions.
31 changes: 18 additions & 13 deletions E5_cov_real.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,15 @@
'INSECTS-incremental'
]

fig, axx = plt.subplots(6,2, figsize=(8,20), sharex=True, sharey=True)
fig, axx = plt.subplots(2,6, figsize=(20,7.5), sharex=True, sharey=True)

axx[0,0].set_title('ALL')
axx[0,1].set_title('STD')
axx[0,0].set_ylabel('ALL')
axx[1,0].set_ylabel('STD')

for f_id, f in enumerate(real_streams):

res = np.load('results/combined_real_%i.npy' % f_id)
print(res.shape) # features+label, drifts, reps, chunks

X = res[indexes]
print(X.shape)

# cov entire dataset
X_all = np.copy(X)
Expand All @@ -41,21 +38,25 @@

c = np.abs(np.cov(X_all))

ax = axx[f_id,0]
ax = axx[0, f_id]
ax.set_ylabel('%s' % (f))
ax.imshow(c, cmap='Greys')
# print(np.nanmin(c), np.nanmax(c))
im = ax.imshow(c, cmap='Greys', vmin=0, vmax=1)
ax.set_xticks(range(len(labels)), labels, rotation=90)
ax.set_yticks(range(len(labels)), labels)

cax_2 = axx[0,-1].inset_axes([1.04, 0.0, 0.05, 1.0])
fig.colorbar(im, ax=axx[0,0], cax=cax_2)

# calculate for metachunk
collected=[]
window = 25

for i in range(int(X.shape[-1]/window)):

print(i*window,(i+1)*window)
# print(i*window,(i+1)*window)
X_w = X[:,i*window:(i+1)*window]
print(X_w.shape)
# print(X_w.shape)

for a in range(len(labels)):
m = np.mean(X_w[a])
Expand All @@ -69,12 +70,16 @@

std_collected = np.std(np.array(collected), axis=0)
# std_collected = np.mean(np.array(collected), axis=0)
ax = axx[f_id,1]
ax.imshow(std_collected, cmap='Greys')
ax = axx[1,f_id]
im = ax.imshow(std_collected, cmap='Greys',vmin=0,vmax=0.4)
ax.set_xlim(std_collected.shape[0]-.5,-.5)

ax.set_xticks(range(len(labels)), labels, rotation=90)
ax.set_yticks(range(len(labels)), labels)


cax_2 = axx[1,-1].inset_axes([1.04, 0.0, 0.05, 1.0])
fig.colorbar(im, ax=axx[0,0], cax=cax_2)

plt.tight_layout()
plt.savefig('figures/fig_clf/cov_real.png')
plt.savefig('figures/fig_clf/cov_real.eps')
26 changes: 17 additions & 9 deletions E5_cov_semi.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
]


fig, axx = plt.subplots(6,2, figsize=(8,20), sharex=True, sharey=True)
axx[0,0].set_title('MEAN ALL')
axx[0,1].set_title('STD')
fig, axx = plt.subplots(2,6, figsize=(20,7.5), sharex=True, sharey=True)
axx[0,0].set_ylabel('MEAN ALL')
axx[1,0].set_ylabel('STD')

res = np.load('results/combined_semi.npy')
print(res.shape) # features+label, drifts, reps, chunks
Expand All @@ -46,12 +46,17 @@
covs.append(c)

covs = np.mean(np.array(covs),axis=0)
ax = axx[rep,0]
ax.set_ylabel('%s' % (streams[rep]))
ax.imshow(c, cmap='Greys')
ax = axx[0,rep]
ax.set_title('%s' % (streams[rep]))
print(np.nanmin(c), np.nanmax(c))

im = ax.imshow(c, cmap='Greys', vmin=0, vmax=1)
ax.set_xticks(range(len(labels)), labels, rotation=90)
ax.set_yticks(range(len(labels)), labels)

cax_2 = axx[0,-1].inset_axes([1.04, 0.0, 0.05, 1.0])
fig.colorbar(im, ax=axx[0,0], cax=cax_2)


# calculate for metachunk

Expand Down Expand Up @@ -81,14 +86,17 @@

collected = np.array(collected)
collected_std = np.std(collected, axis=0)
ax = axx[rep,1]
#ax.imshow(collected_std, cmap='Greys')
ax.imshow(collected_std, cmap='Greys')
ax = axx[1,rep]
# print(np.nanmin(collected_std), np.nanmax(collected_std))
im = ax.imshow(collected_std, cmap='Greys', vmin=0, vmax=0.2)
ax.set_xlim(collected_std.shape[0]-.5,-.5)
ax.set_xticks(range(len(labels)), labels, rotation=90)
ax.set_yticks(range(len(labels)), labels)

cax_2 = axx[1,-1].inset_axes([1.04, 0.0, 0.05, 1.0])
fig.colorbar(im, ax=axx[0,0], cax=cax_2)

plt.tight_layout()
plt.savefig('figures/fig_clf/cov_semi.png')
plt.savefig('figures/fig_clf/cov_semi.eps')

25 changes: 16 additions & 9 deletions E5_cov_syn.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

drifts = ['Sudden', 'Gradual', 'Incremental']

fig, axx = plt.subplots(3,2, figsize=(8,10), sharex=True, sharey=True)
axx[0,0].set_title('MEAN ALL')
axx[0,1].set_title('STD')
fig, axx = plt.subplots(2,3, figsize=(11,7), sharex=True, sharey=True)
axx[0,0].set_ylabel('MEAN ALL')
axx[1,0].set_ylabel('STD')


# cov entire dataset
Expand All @@ -40,12 +40,15 @@
covs.append(c)

covs = np.mean(np.array(covs),axis=0)
ax = axx[drift,0]
ax.set_ylabel('%s' % (drifts[drift]))
ax.imshow(c, cmap='Greys')
ax = axx[0,drift]
ax.set_title('%s' % (drifts[drift]))
im = ax.imshow(c, cmap='Greys', vmin=0, vmax=1)
# print(np.nanmin(c), np.nanmax(c))
ax.set_xticks(range(len(labels)), labels, rotation=90)
ax.set_yticks(range(len(labels)), labels)

cax_2 = axx[0,-1].inset_axes([1.04, 0.0, 0.05, 1.0])
fig.colorbar(im, ax=axx[0,0], cax=cax_2)

# calculate for metachunk

Expand Down Expand Up @@ -75,12 +78,16 @@

collected = np.array(collected)
collected_std = np.std(collected, axis=0)
ax = axx[drift,1]
ax.imshow(collected_std, cmap='Greys')
ax = axx[1,drift]
im = ax.imshow(collected_std, cmap='Greys', vmin=0, vmax=0.1)
ax.set_xlim(collected_std.shape[0]-.5,-.5)
ax.set_xticks(range(len(labels)), labels, rotation=90)
ax.set_yticks(range(len(labels)), labels)

cax_2 = axx[1,-1].inset_axes([1.04, 0.0, 0.05, 1.0])
fig.colorbar(im, ax=axx[0,0], cax=cax_2)


plt.tight_layout()
plt.savefig('figures/cov_syn.png')
plt.savefig('figures/fig_clf/cov_syn.png')
plt.savefig('figures/fig_clf/cov_syn.eps')
Loading

0 comments on commit 6438bfe

Please sign in to comment.