-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRC_Analysis.jl
256 lines (238 loc) · 8.74 KB
/
RC_Analysis.jl
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
################################################################################
## This script is for creating plots for the BNs in RC project
## Current plots include:
##
################################################################################
using Plots
filepath = "C:/Users/ChuperDuper/Documents/Thesis/Experiments/Simulations/ReservoirComputers"
N = [10; 20; 30; 40; 50; 100; 200; 300; 400; 500]
L = [10:10:100;]
K = 2
numN = length(N)
numL = length(L)
numRes = 100
numF = 2^2^3
# Import Data
data = readcsv("$(filepath)/output_all3bit_bias0.5_training150_stream10_delay1_$(numRes)experiments.csv")
data_f64 = convert(Array{Float64,2},data[2:end,:])
# Mean accuracy for median function
# Median function ID = 23
funID = 23
#takemeanoverR(permutetoNxLxR(reshapeintoLxNxR(pull out data only for median)))
data_metric = mean(permutedims(reshape(data_f64[data_f64[:,5].==funID,6],numL,numN,numRes),[2,1,3]),3)
fig = heatmap(reshape(data_metric,numN,numL),
title = "Mean Accuracy - 3-bit Median",
clim = (0.5,1),
#color=:gray,
colorbar_title="Mean Accuracy",
xtickfont = font(10,"TimesNewRoman"),
xlabel = "L - % Nodes Connected to Input Layer",
xtick = ([1:numL;],string.(unique(data[2:end,4]))),
ytickfont = font(10,"TimesNewRoman"),
ytick = ([1:numN;],string.(unique(data[2:end,3]))),
ylabel="Size of Reservoir",
guidefont = font(12))
savefig(fig,"$(filepath)/K$(K)_MeanAccuracy_median")
# Mean accuracy for parity function
# Parity function ID = 105
funID = 105
#takemeanoverR(permutetoNxLxR(reshapeintoLxNxR(pull out data only for median)))
data_metric = mean(permutedims(reshape(data_f64[data_f64[:,5].==funID,6],length(L),length(N),numRes),[2,1,3]),3)
fig = heatmap(reshape(data_metric,numN,numL),
title = "Mean Accuracy - 3-bit Parity",
clim = (0.5,1),
#color=:gray,
colorbar_title="Mean Accuracy",
xtickfont = font(10,"TimesNewRoman"),
xlabel = "L - % Nodes Connected to Input Layer",
xtick = ([1:numN;],string.(unique(data[2:end,4]))),
ytickfont = font(10,"TimesNewRoman"),
ytick = ([1:numL;],string.(unique(data[2:end,3]))),
ylabel="Size of Reservoir",
guidefont = font(12))
savefig(fig,"$(filepath)/K$(K)_MeanAccuracy_parity")
# Mean accuracy for all functions
#takemeanoverRandF(permutetoNxLxFxR(reshapeintoFxLxNxR))
data_metric = mean(permutedims(reshape(data_f64[:,6],numF,numL,numN,numRes),[3,2,1,4]),[3 4])
fig = heatmap(reshape(data_metric,numN,numL),
title = "Mean Accuracy - All 3-bit Functions",
clim = (0.5,1),
#color=:gray,
colorbar_title="Mean Accuracy",
xtickfont = font(10,"TimesNewRoman"),
xlabel = "L - % Nodes Connected to Input Layer",
xtick = ([1:numL;],string.(unique(data[2:end,4]))),
ytickfont = font(10,"TimesNewRoman"),
ytick = ([1:numN;],string.(unique(data[2:end,3]))),
ylabel="Size of Reservoir",
guidefont = font(12))
savefig(fig,"$(filepath)/K$(K)_MeanAccuracy_all")
# Mean accuracy across all functions (with a given N,L)
#takemeanoverR(permutetoNxLxFxR(reshapeintoFxLxNxR))
data_metric = mean(permutedims(reshape(data_f64[:,6],numF,numL,numN,numRes),[3,2,1,4]),4)
fig = plot(layout=(numN,numL))
count = 0
for i = 1:numN # N
for j = 1:numL # L
count+=1
histogram!(data_metric[end-i+1,j,:,1], # go from end of rows because N goes increases from top to bottom
subplot=count,
#title = "",
#nbins = 11, #A
nbins = [0:0.1:1.1;], #B
#xlim = (-0.05,1.15),
ylim = (0,numF),
legend = false,
#ylabel = "# of Tissues",
#xlabel = "log # of All Observed CAs",
#ytickfont = font(30,"TimesNewRoman"),
ytick = false,
#xtickfont = font(30,"TimesNewRoman"),
#guidefont = font(30),
#titlefont = font(30),
xtick = false)
end
end
plot(fig)
savefig(fig,"$(filepath)/K$(K)_MeanAccuracy_functionHistA")
# Histogram of accuracies for a single reservoirs
data_metric = permutedims(reshape(data_f64[:,6],numF,numL,numN,numRes),[3,2,1,4])
for i = 1:numN # N
for j = 1:numL # L
fig = plot(layout=(10,10))
for k = 1:numRes # Reservoir ID
histogram!(data_metric[i,j,:,k],
subplot=k,
#title = "",
nbins = [0:0.1:1.1;],
xlim = (-0.05,1.15),
ylim = (0,numF),
legend = false,
#ylabel = "# of Tissues",
#xlabel = "log # of All Observed CAs",
#ytickfont = font(30,"TimesNewRoman"),
ytick = false,
#xtickfont = font(30,"TimesNewRoman"),
#guidefont = font(30),
#titlefont = font(30),
xtick = false)
end
savefig(fig,"$(filepath)/MeanAccuracy_functionHist_N$(N[i])L$(L[j])")
end
end
# histogram for 1 network
fig = histogram(data_metric[10,10,:,1],
title = "N = $(N[10]), L = $(L[10])",
nbins = [0:0.1:1.1;],
xlim = (-0.0,1.15),
ylim = (0,numF),
legend = false,
ylabel = "# of Functions",
xlabel = "Accuracy",
ytickfont = font(20,"TimesNewRoman"),
ytick = true,
xtickfont = font(20,"TimesNewRoman"),
guidefont = font(20),
titlefont = font(20),
xtick = true)
savefig(fig,"$(filepath)/MeanAccuracy_functionHist_N$(N[10])L$(L[10])R1")
# Histogram of sum(# of >90% accuracy functions) across all reservoirs
data_metric = sum(permutedims(reshape(data_f64[:,6],numF,numL,numN,numRes),[3,2,1,4]).>0.9,3)./numF
fig = plot(layout=(numN,numL))
count = 0
for i = 1:numN # N
for j = 1:numL # L
count+=1
histogram!(data_metric[end-i+1,j,1,:],
subplot=count,
#title = "",
nbins = [0:0.1:1.1;],
xlim = (-0.05,1.15),
ylim = (0,numRes),
legend = false,
#ylabel = "# of Tissues",
#xlabel = "log # of All Observed CAs",
#ytickfont = font(30,"TimesNewRoman"),
ytick = false,
#xtickfont = font(30,"TimesNewRoman"),
#guidefont = font(30),
#titlefont = font(30),
xtick = false)
end
end
savefig(fig,"$(filepath)/K$(K)_MeanAccuracy_GT90AccuracyHist")
# Mean accuracy Vs. Function Sensitivity
f_sens = readdlm("$(filepath)/AverageSensitivities_all3bit.txt",Float64)
data_metric = mean(permutedims(reshape(data_f64[:,6],numF,numL,numN,numRes),[3,2,1,4]),4)
# For NxL grid of subplots
fig = plot(layout=(numN,numL))
count = 0
for i = 1:numN # N
for j = 1:numL # L
count+=1
scatter!(f_sens[:],data_metric[end-i+1,j,:,1],
subplot=count,
#title = "",
xlim = (-0.2,3.2),
#ylim = (-0.1,1.1), #A
ylim = (minimum(data_metric[end-i+1,j,:,1]),maximum(data_metric[end-i+1,j,:,1])), #B
legend = false,
#ylabel = "# of Tissues",
#xlabel = "log # of All Observed CAs",
#ytickfont = font(30,"TimesNewRoman"),
ytick = false,
#xtickfont = font(30,"TimesNewRoman"),
#guidefont = font(30),
#titlefont = font(30),
xtick = false)
end
end
savefig(fig,"$(filepath)/K$(K)_SensitivityVsMeanAccuracyB")
# For 3 L values on one plot
for i = [1 5 10] # N
fig = plot()
for j = [1 5 10] # L
scatter!(f_sens[:],data_metric[i,j,:,1],
markersize = 12,
title = "N = $(N[i])",
xlim = (-0.2,3.2),
ylim = (-0.1,1.1),
legend = :bottomleft,
legendfont = font(20,"TimesNewRoman"),
label = ("L = $(L[j])"),
xlabel = "Function Average Sensitivty",
ylabel = "Mean Accuracy",
ytickfont = font(20,"TimesNewRoman"),
ytick = true,
xtickfont = font(20,"TimesNewRoman"),
guidefont = font(20),
titlefont = font(20),
xtick = true)
end
savefig(fig,"$(filepath)/K$(K)_SensitivityVsMeanAccuracy_N$(N[i])")
end
# mean accuracy v function ID (should be symmetrical)
data_metric = mean(permutedims(reshape(data_f64[:,6],numF,numL,numN,numRes),[3,2,1,4]),4)
fig = plot(layout=(numN,numL))
count = 0
for i = 1:numN # N
for j = 1:numL # L
count+=1
bar!(data_metric[end-i+1,j,:,1],
subplot=count,
#title = "",
#xlim = (-0.2,3.2),
#ylim = (-0.1,1.1),
#ylim = (minimum(data_metric[end-i+1,j,:,1]),maximum(data_metric[end-i+1,j,:,1])),
legend = false,
#ylabel = "# of Tissues",
#xlabel = "log # of All Observed CAs",
#ytickfont = font(30,"TimesNewRoman"),
ytick = false,
#xtickfont = font(30,"TimesNewRoman"),
#guidefont = font(30),
#titlefont = font(30),
xtick = false)
end
end
plot(fig)