Exemple #1
0
            for a_indx, algorithm in enumerate(algorithms):
                regret[a_indx, m_indx, s] = algorithm.run(T, model)

    return regret, models


experiment = Experiment(1)
experiment.log_code()

# Experiment 1
N = 50
epsilon = .3
simulations = 10000
T = 400
algorithms = [
    GeneralCausal(truncate='None'),
    ParallelCausal(),
    SuccessiveRejects(),
    AlphaUCB(2),
    ThompsonSampling()
]
m_vals = range(2, N, 2)

regret, models = regret_vs_m(algorithms,
                             m_vals,
                             N,
                             T,
                             epsilon,
                             simulations=simulations)

experiment.plot_regret(regret,
Exemple #2
0
                
    
    return m_vals,regret,models
    
   
experiment = Experiment(4)
experiment.log_code()
    
N = 50
N1_vals = range(1,N,3)
pz = .4
q = (0.00001,0.00001,.4,.65)
epsilon = .3
simulations = 10000
T = 400
algorithms = [SuccessiveRejects(),GeneralCausal(),AlphaUCB(2),ThompsonSampling()]


epsilon = .3
pY = ParallelConfounded.pY_epsilon_best(q,pz,epsilon)

m_vals,regret,models = regret_vs_m_general(algorithms,N1_vals,N,T,pz,pY,q,epsilon,simulations = simulations)
experiment.plot_regret(regret,m_vals,"m",algorithms,legend_loc = "lower right",legend_extra = [ParallelCausal])







Exemple #3
0
    return regret, pulls


experiment = Experiment(6)
experiment.log_code()

N = 50
N1 = 1
pz = .4
q = (0.00001, 0.00001, .4, .65)
epsilon = .3
pY = ParallelConfounded.pY_epsilon_best(q, pz, epsilon)

simulations = 10000

model = ScaleableParallelConfounded(q, pz, pY, N1, N - N1)

T_vals = range(25, 626, 25)

algorithms = [
    GeneralCausal(),
    SuccessiveRejects(),
    AlphaUCB(2),
    ThompsonSampling()
]

regret, pulls = regret_vs_T(model, algorithms, T_vals, simulations=simulations)

experiment.plot_regret(regret, T_vals, "T", algorithms, legend_loc=None)
Exemple #4
0
pY = np.asarray([[.4, .4], [.7, .7]])

models = [
    ScaleableParallelConfounded(q, pz, pY, N1, N - N1)
    for N1 in range(29, 36, 2)
]

#model = ScaleableParallelConfounded(q,pz,pY,33,N-33)

#print "built model 1"

#model2 = ScaleableParallelConfounded(q,pz,pY,35,N-35)

print "built model 2"

alg = GeneralCausal()

regret = np.zeros((len(models), 1000), dtype=float)
pulls = np.zeros((len(models), 1000, models[0].K), dtype=int)
for s in xrange(1000):
    for i, model in enumerate(models):
        regret[i, s] = alg.run(T, model)
        pulls[i, s, alg.best_action] += 1

etas = [model.contract(model.eta) for model in models]
print regret.mean(axis=1)
for e in etas:
    print e

en = [[0, 0, 1 / (N1 + 6), 0, 0, 0, 1 - N1 / (N1 + 6)]
      for N1 in range(29, 36, 2)]