Bandit Algorithms in Clojure. Uploaded 2017, but it is actually a talk from 2013. Bandit Algorithms are reinforcement learning algorithms. They are really great for automating the A/B testing of important features. The talk shows how to package and call Clojure code in a way that it can be called from Java or other JVM languages, too.
1 of 49
Download to read offline
More Related Content
Clojure: Programming self-optimizing webapps in Lisp
2. 息 freiheit.com technologies gmbh
Welcome, Earthlings!
My name ist Stefan Richter
I am a programmer, engineer and computer scientist
I started programming in 1983 on an Apple ][ (UCSD Pascal)
Worked in polar research, software development & consulting
In 1999, I founded freiheit.com technologies gmbh
We are building large-scale internet systems
70 people. 90% programmers with a strong academic background
We mostly use Java and JavaScript
Today I want to show you how to have fun with Lisp (Clojure)
10. 息 freiheit.com technologies gmbh
Objectives of this talk
We will learn what multi-armed bandit algorithms are
We will write a Clojure library for the epsilon-greedy algorithm
Two approaches: Naive and idiomatic
I will show you some nice features of the Clojure language
We will make our library thread-safe by using agents
And we will expose our Clojure library as a JAR-File to use it from
an ordinary Java program
So in the end youll get an idea of how you can write Lisp/Clojure
code and use it as a library from within your Java apps. ;)
11. 息 freiheit.com technologies gmbh
Multi-armed bandit
algorithms
Which arms on which
machines would you draw
based on the past outcome
(reward)?
Exploration vs. exploitation
What do you need?
select-arm()
update()
algorithms: epsilon-
greedy, Softmax, UCB etc.
16. 息 freiheit.com technologies gmbh
Whats wrong with the naive implementation?
Code must know what to expect at which vector index.
Vector index access is diffcult to read/grasp.
The functions have no cohesion. They are just named functions
that accidentally work together on the same datastructure, a
vector.
How can we implement different algorithm versions that provide
the same interface functions (select-arm, update)?
The code isnt self-explanatory. How do you should use the
functions?
19. 息 freiheit.com technologies gmbh
Naive and idiomatic: Almost the same SLOCs
Much better now. More readable and understandable.
We are now accessing the different fields the algorithm needs by
name instead of by index.
We defined a datastructure and implemented functions that are
working on this datastructure based on a protocol (interface).
We can create many different implementations of the
BanditAlgorithm protocol.
And along the way, a new Java class and interface are generated!
20. 息 freiheit.com technologies gmbh
Demo-Time!
Interactive programming
(again), protocols and records,
sequences revisited (maps),
immutability or the absence
of state (again)
29. 息 freiheit.com technologies gmbh
Programming multi-armed bandit algorithms
in Go
- Release 0.1 -
Developer Conference 2013
Hamburg, November 7th/8th 2013
30. 息 freiheit.com technologies gmbh
Welcome, Earthlings!
My name ist Stefan Richter
I am a programmer, engineer and computer scientist
I started programming in 1983 on an Apple ][ (UCSD Pascal)
Worked in polar research, software development & consulting
In 1999, I founded freiheit.com technologies gmbh
We are building large-scale internet systems
70 people. 90% programmers with a strong academic background
We mostly use Java and JavaScript
Today I want to show you how to have fun with Go and in about
one hour I will show how to solve the same problem in Clojure.
38. 息 freiheit.com technologies gmbh
Objectives of this talk
We will learn what multi-armed bandit algorithms are
We will write a Golang program for the epsilon-greedy algorithm
I will show you some nice Golang features
This prepares you for my next talk today at 1600 in Kinosaal 2
39. 息 freiheit.com technologies gmbh
Multi-armed bandit
algorithms
Which arms on which
machines would you draw
based on the past outcome
(reward)?
Exploration vs. exploitation
What do you need?
selectArm()
update()
algorithms: epsilon-
greedy, Softmax, UCB etc.
41. 息 freiheit.com technologies gmbh
Not really trendy...
Go is not object-oriented
Good thing: You cant mess up your code with Enterprise
patterns... ;)
Go doesnt support functional programming
But you can define your own types
And you have duck typing and interfaces
It is like C without the bad parts
(I think almost every language in the past 30 years was made to
fix the problems of C - and along the way new problems were
created)