In [1]:
import matplotlib.pyplot as plt
import pylab as pl
import scipy.io as sio
import numpy as np
import cPickle as cp
import csv, glob, os
In [10]:
def data_stats(setname):
data = np.zeros((16,))
for fname in glob.glob("Slogs/" + str(setname) + "_*"):
c_data = []
rfile = open(fname, 'r')
for row in rfile:
if not row.startswith("#"):
proc = row.strip().split(" ")
c_data.append(proc[3])
c_data = np.asarray(c_data, dtype=np.float32)
best = np.min(c_data)
subj_str = fname[14:16]
if subj_str[-1] == "_": subj_str = fname[14]
subject = int(subj_str)
data[subject] = best
data = np.asarray(data)
return data
In [13]:
ssdec = (1-data_stats("SSALL")).reshape(-1,1)
np.mean(ssdec)
Out[13]:
In [22]:
def CV_stats():
data = np.zeros((16))
for fname in glob.glob("TCV_SSMS" + "_*"):
c_data = []
rfile = open(fname, 'r')
for row in rfile:
if not row.startswith("#"):
proc = row.strip().split(" ")
c_data.append(proc[3])
c_data = np.asarray(c_data, dtype=np.float32)
best = np.min(c_data)
subject = int(fname[15:])
data[subject] = best
data = np.asarray(data)
return data
In [24]:
np.mean(CV_stats())
Out[24]:
In [24]:
def get_data(logname):
c_data = []
rfile = open(logname, 'r')
for row in rfile:
if not row.startswith("#"):
proc = row.strip().split()
c_data.append(proc)
data = np.asarray(c_data)
err_data = np.asarray(data[:,1:5], dtype=np.float32)
return err_data
In [3]:
def proc_data(data_in):
mu = data_in.mean(axis=0)
std = data_in.std(axis=0)
return np.concatenate([np.arange(len(mu)).reshape(-1,1), mu, std], axis=1)
In [4]:
%matplotlib inline
In [5]:
plot_info = []
data2 = proc_data(get_data("500l3", "0.80"))
plot_info.append({'X': data2[:,0], 'Y': data2[:,2], 'YSTD': data2[:,4], 'label': "0.80", 'color': 'b'})
data2 = proc_data(get_data("500l3", "0.90"))
plot_info.append({'X': data2[:,0], 'Y': data2[:,2], 'YSTD': data2[:,4], 'label': "0.90", 'color': 'g'})
data2 = proc_data(get_data("500l3", "0.98"))
plot_info.append({'X': data2[:,0], 'Y': data2[:,2], 'YSTD': data2[:,4], 'label': "0.98", 'color': 'r'})
In [27]:
data2 = get_data("test")
X, Y = data2[:,0], data2[:,3]
plt.plot(np.log(1+X), Y)
plt.legend()
plt.axhline(0.09, color='k', linestyle='--')
plt.xlabel('Epoch')
plt.ylabel('CV classification score (% correct)')
plt.show()
In [ ]:
def gen_plot(X, Y, YSTD, item, show=False):
plt.plot(X, Y, label=item)
plt.axhline(0.50, color='k', linestyle='--',
label="Chance level")
#plt.axvline(0, color='r', label='stim onset')
plt.legend()
hyp_limits = (Y - YSTD, Y + YSTD)
plt.fill_between(X, hyp_limits[0],
y2=hyp_limits[1], color='b', alpha=0.5)
plt.xlabel('Epoch')
plt.ylabel('CV classification score (% correct)')
#plt.ylim([30, 100])
plt.title('Momentum parameter tests')
if show:
plt.show()
else:
plt.savefig("plots/"+item+"plot.png")
plt.clf()
In [ ]:
#items = ["0.80", "0.90", "0.91", "0.92", "0.93", "0.94", "0.95", "0.98"]
#items = ["0.020", "0.010", "0.005", "0.002"]
#items = ["20_", "40_", "60_", "80_", "100_"]
#items = ["100_", "200_", "300_", "400_", "500_"]
items = ["0_", "2_", "5_", "7_", "8_", "12_"]
for item in items:
data1 = get_data("rawMCV", item)
data2 = proc_data(data1)
#np.savetxt("plog_"+item, data2, fmt='%.5e')
gen_plot(data2[:,0], data2[:,2], data2[:,4], item)