In [1]:
%pylab inline


Populating the interactive namespace from numpy and matplotlib

Read


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()


theta
[0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0]
adaptive_lda_0.1
adaptive_lda_0.5
adaptive_lda_1.0
em
lda
phi
[0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0]
adaptive_lda_0.1
adaptive_lda_0.5
adaptive_lda_1.0
em
lda
prod
[0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0]
adaptive_lda_0.1
adaptive_lda_0.5
adaptive_lda_1.0
em
lda