from batch import Batched from coba.benchmarks import Benchmark import re def baseLearner(): from coba.learners import VowpalLearner return VowpalLearner(seed=10, epsilon=0.1, flags='--coin') learner_factories = [ Batched(delay=8, batchsize=1, learner=baseLearner), Batched(delay=8, batchsize=2, learner=baseLearner), Batched(delay=8, batchsize=4, learner=baseLearner), Batched(delay=8, batchsize=8, learner=baseLearner), ] processes = 4 maxtasksperchild = 1 json = "./exp.json" log = re.sub('json$', 'log', json) if __name__ == '__main__': result = Benchmark.from_file(json).processes(processes).maxtasksperchild( maxtasksperchild).evaluate(learner_factories, log) result.standard_plot()
""" This is an example script that creates a Benchmark that matches the bandit bakeoff paper. This script requires that the matplotlib and vowpalwabbit packages be installed. """ from coba.learners import RandomLearner, EpsilonLearner, VowpalLearner, UcbTunedLearner, CorralLearner from coba.benchmarks import Benchmark if __name__ == '__main__': benchmark = Benchmark.from_file("./examples/benchmark_short.json") learners = [ RandomLearner(), EpsilonLearner(epsilon=0.025), UcbTunedLearner(), VowpalLearner(bag=5, seed=10), CorralLearner([VowpalLearner(bag=5, seed=10), UcbTunedLearner()], eta=.075, T=40000, seed=10), ] benchmark.evaluate(learners, './examples/bakeoff.log', seed=10).standard_plot()