The mutator

This time we consider a mutator with memory, first obtain the code from:
Then load it into julia:
julia -L AI2

Create the mutator and its neural network:

The mutator keeps track of the network, now we need some training samples.

Examples consist of bars describing how dispersed the previous hundred trades were and a target value to assign to these bars depending on how fast two bids on the spread are bought.

The net is untrained so the result is random:

Let’s poke it.

The mutator pokes the net in various ways to make it conform to the target and also remembers the effect of poking a specific node, maximum score per example is 1.

Ever had your brain poked continuously a thousand times?
for poke in 1:1000;println(poke!(mutator,example,target));end
score(,example,target) #0.9999999

Let’s see what result we get on several samples

The score function is overloaded to handle sample arrays.

The poke! function also, the exclamation point is a julia convention for functions that modify their arguments.

The overloaded poker pokes once for each sample, because of this the end result is sometimes worse. So we use the pocket algorithm, it works like this: we take the best result so far, and put it in our pocket.

The pocket algorithm is part of the evolve function, let’s do ten iterations:

Each time a better net is pocketed the new score is printed. Let’s evolve a lot.

After a while the rate of improvement decreases, this means we need to decrease the mutation factor which defaults to 0.1, a value that determines the strength of the poke!

Next up we will download the full trade history and make the mutator more agile.


About jhlq

"The leaf and his body were one. Neither possessed a separate permanent self. Neither could exist independently from the rest of the universe."
This entry was posted in Miscellaneous. Bookmark the permalink.

Spread a little love

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s