In [1]:
from extractMeanStdPSO import *
%load_ext autoreload
%autoreload 2
%matplotlib inline

In [5]:
fileName = "DOG_WorkingMemory_100_"
dir = "expPSO/DOG_WorkingMemory_100/"
repet= 50
nbEpoch=9900
batch = Batch.initOrLoad(dir,fileName,repet)


Batch not present. Reading files...
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
Saving batch
Batch loaded

In [6]:
batch.saveFitnessEvolution()


saving :  expPSO/DOG_WorkingMemory_100/fitnessEvolution.csv

In [13]:
batch.saveBestInd()
del batch


saving :  expPSO/DOG_WorkingMemory_100/bestInd.pi

In [8]:
array = np.loadtxt("expPSO/pso_DOG_competition/fitnessEvolution.csv")
mean = np.mean(array,axis=1)
std = np.std(array,axis=1)/2.0
X = np.arange(nbEpoch)
plt.fill_between(X, mean - std,mean + std,color="green")
plt.plot(X, mean, color="white", lw=1)
plt.xlim(0,nbEpoch)
plt.xlabel("Epoch")
plt.ylabel("Mean RMSE")


Out[8]:
<matplotlib.text.Text at 0x7f8f0bce8b70>

In [8]:



saving :  expPSO/pso_DOG_competitionbestInd.pi

In [9]:
bestInd = Batch.loadBestInd(dir+"bestInd.pi")

In [10]:
def loadParams(paramList):    
    parameters = {}
    for param in paramList:
        parameters[param] = [d[param] for d in bestInd]
    return parameters

In [11]:
params = loadParams(['iExc','iInh','wExc','wInh','h','th','tau'])

In [12]:
plt.figure(figsize=(10,10))
plt.subplot(221)
plt.plot(params['h'])
plt.plot(params['th'])
plt.subplot(222)
plt.plot(params['iExc'])
plt.plot(params['iInh'])
plt.subplot(223)
plt.plot(params['wExc'])
plt.plot(params['wInh'])
plt.subplot(224)
plt.plot(params['tau'])


Out[12]:
[<matplotlib.lines.Line2D at 0x7f8f0bb82d30>]

In [37]:
plt.plot(np.array(params['h'])-np.array(params['th']))


Out[37]:
[<matplotlib.lines.Line2D at 0x7fc006977ef0>]

In [35]:
fig, ax = plt.subplots()

mat = []
keys = ['not']
#row must be variable
for k in params.keys():
    mat.append(params[k])
    keys.append(k)
print(keys)
mat = [params[i] for i in params.keys()]
mat = np.array(mat)
print(mat.shape)
corr = np.corrcoef(mat)
plt.imshow(corr,interpolation='None',cmap='RdYlBu_r')
plt.clim(-1,1)
ax.set_xticklabels(keys)
ax.set_yticklabels(keys)
plt.colorbar()


['not', 'iInh', 'h', 'tau', 'th', 'wInh', 'wExc', 'iExc']
(7, 50)
Out[35]:
<matplotlib.colorbar.Colorbar at 0x7f8f1bdb40f0>

In [ ]: