In [1]:
%pylab inline
In [20]:
import collections
def hasher():
return collections.defaultdict(hasher)
errors = hasher()
alphas = set()
matrices = set()
algorithms = set()
with open('results', 'r') as results_file:
for line in results_file.readlines():
run, alpha, algorithm, matrix, error = line.rstrip().split("\t")
matrices.add(matrix)
algorithms.add(algorithm)
alpha = float(alpha)
alphas.add(alpha)
error = float(error)
#print run, algorithm, error
errors[matrix][alpha][algorithm][run] = error
#print matrices
alphas = sorted(list(alphas))
#print alphas
fig = figure(figsize=(15,25))
for i, matrix in enumerate(matrices):
print matrix
ax = fig.add_subplot(3,1,i+1)
ax.set_xlabel('alpha')
ax.set_ylabel(matrix+' error')
algorithm_mean_errors = {a:[] for a in algorithms}
algorithm_std_errors = {a:[] for a in algorithms}
for alpha in alphas:
for algorithm in algorithms:
algo_errs = []
for run in errors[matrix][alpha][algorithm]:
algo_errs.append(errors[matrix][alpha][algorithm][run])
algo_errs = array(algo_errs)
algorithm_mean_errors[algorithm].append(algo_errs.mean())
algorithm_std_errors[algorithm].append(algo_errs.std())
print alphas
for algorithm in sorted(algorithms):
#print algorithm_mean_errors[algorithm]
print algorithm
#errorbar(alphas, algorithm_mean_errors[algorithm], algorithm_std_errors[algorithm])
plot(alphas, algorithm_mean_errors[algorithm],label=algorithm)
rcParams.update({'font.size': 20})
legend()