I programmed my £30 Raspberry Pi to automate picking football tips using machine learning techniques, which you can follow on twitter @PiBot_predicts
I say, anyone for tennis?
A while back I blogged about the potential of using predictive modelling for betting on Tennis.
I commented that bookmakers would likely tune their odds to maximise their profits based on what bets they had taken and what they would be likely to take. Therefore the bookmaker’s implied probability would sometimes be significantly different to “actual” probability and machine learning could be used to identify the most under-valued picks. I hypothesised that as tennis is largely enjoyed for the sport itself and as such there would be a lot of data published on each match which could be exploited for profit.
The ATP makes available a good selection of stats, first serve in % etc… but for the WTA all we easily get it the sets box-score. Which is a shame as if forces you to either halve the number of observations or drastically reduces the number of variables you can use. Sadly I conclude there’s not enough data on enough matches.
That thing they show at the end of the news
With tennis ruled out, on to football. Tennis and horse racing data is locked away, either by broadcasters or pay-wall APIs. Football by contrast is just always in your face. I have no interest in football but even I have a rough awareness of what’s going on. With four divisions widely reported on in the UK there is a lot of consistent data available, and a lot of potential match-ups to predict against.
Raspberry Ry
I have been wanting to do something significant with my Raspberry Pi for a while now, and automating picking betting tips seemed like a fun project.
I wrote a number of scripts to scrape a few sites for past results and upcoming fixture odds and the scripts I used to generate the initial training data were re-used on this new data. My predictions are then made for the following day’s games and top picks are selected based on those theoretically returning a profit combining book-maker’s implied with my predicted probability.
The model was initially trained on my gaming laptop (because why wouldn’t you want to use a GPU) so porting the code to run on an ARM device was less simple than I had hoped.
I chose to implement much of the logic in R as I’m much more familiar with this than Python. Unfortunately the R version available on raspbian’s apt-get repo was 3.1.1 which is not up to date enough to install the current version of the R library dplyr. And also not up to date enough to install the R library devtools to install a previous version… compile from source it was then. Took about two hours to compile on the Pi humming at 99% CPU utilisation but helpfully this gives me the same version on the Pi as I am running on my laptop.
Now it’s time to sit back and watch the money roll in.
Moneyball
Slight lie, I don’t actually bet any of my own money on this because I’m not entirely confident it works. I cross-validated against the 2016/2017 season, and then again including the year to date as depicted in the below plot.
The chart shows large fluctuations in success, plus a lot of loosing bets are made. In this simulation the bot comes out ahead, barely. And it may have ended on a peak. Making £25 net profit from 326x £1 bets over a year isn’t a stunning return, so instead I programmed the Raspberry Pi to post predictions to a blog here: pibotpreds.blogspot.co.uk, and also tweet top tips here: twitter.com/PiBot_predicts
Share/follow/re-tweet if you’re so inclined but please don’t put any money on what a £30 Raspberry Pi says. If you’ve not seen it yet, watch Moneyball. Also read the book.