Showing posts with label premier league. Show all posts
Showing posts with label premier league. Show all posts

Thursday, 4 April 2013

Football Sim: Early predictions for 6/7/8 April 2013

Let's start this one with a quick recap because I haven't done a review for a couple of weeks. Last week wasn't bad. The week before the international break was the model's first loss, but only a small one.

Not enough detail? OK, let's round up the betting at least.

Since I've been calling bets on Wallpapering Fog before the games and playing £10 stakes every game, we've had:

2 March:    + £26.30
9 March:    + £3.30
16 March:  - £3.50
30 March:  + £17.23

Total:   + £43.33

Which as a newbie who'd only ever placed one football bet before February this year, I reckon is not too bad! (Sean Devine didn't score against Man U by the way. Who knew?) I've been tweeting a bit today about projections for what wins would have been if the model had been in place last season too and they're quite promising. Here if you're interested.

Predictions are early this week because I plan to be up a Lake District mountain with a paraglider on Saturday and Sunday. Can't wait, but football first. Here they are then...


Two notable ones this week. The model's more confident than the market odds that the red half of Manchester will be happy on Monday night and it also thinks that West Brom will beat Arsenal.

The Arsenal one's quite interesting. Giroud's away stats are less than impressive and it's really not helping Arsenal's chances of scoring, but the model's also not sure what to do with Rosicky (assuming he starts - line-ups from here) because he hasn't played much this season. I artificially gave him some very healthy shooting stats though, re-ran the model and Arsenal still lost with the chances being a little closer, so I'm going with it as a prediction.

Here are the calls for betting:

West Brom v Arsenal - Home Win
Stoke v Villa - Home Win
Chelsea v Sunderland - Home Win
Spurs v Everton - Home Win
Newcastle v Fulham - Home Win
Liverpool v West Ham - Home Win
Man U v Man City - Home Win
Norwich v Swansea - Draw
QPR v Wigan - Draw
Reading v Southampton - Away Win


By the way, I know I list Home / Away / Draw in the table above and nobody else does it in that order. It's even started annoying me now, so I'll change it for next week!

Saturday, 30 March 2013

Model changes and predictions for this weekend

I've been making some changes to my football model over the international break and its prediction performance has got a little better again. Although with at least one side-effect that we'll see in a second.

Apart from some robustness testing, the biggest change has been adjusting shot success depending on the opponent. The model should handle number of shots and which players take those shots, reasonably well. It simulates the passing of individual players and if you haven't got the ball, you can't shoot, so in the simulation, shot rates will naturally increase against worse teams and drop against better ones, without me having to impose that. When you look at simulated shot stats for a whole season, it does do this job fairly well.

Where the previous version of the model had a problem is that all shots aren't equal. Just for today, let's call this 'The Stoke Effect'.

I've had issues with Stoke in the model since the start. Their pass success rate isn't great and shot conversion rate isn't either, so in the simulation they were predicted to lose a lot more than they did in reality. There is something that Stoke do well though - they force the opposition into taking unsuccessful shots.

I can't impose shot rates on the model, because a big part of shot rates is already simulated through possession. What I can impose is an adjustment factor on the chances of a shot being a goal.

Here are the adjustment factors:



At the moment, I'm not analysing tactics to find out why those numbers look the way they do, I'm just playing with outcomes, but if you're not fussy about pretty football then Stoke are definitely doing something right. I'm also starting to think, "Why don't Stoke get relegated?" might make a fun article for EPL Index, who provide all the stats for this model. Partly as a result of building this model, I'm becoming much more interested in how middling teams get results against the top four (six? Seven so that Liverpool are included? I think those are the rules), than in Man City's most effective attacking combination.

In terms of prediction, Man City should win most of the time and for the purposes of this model, I'm not all that fussed about by how many goals they do it, as long as the result's correct. What's really interesting is whether we can forecast when they won't win. Adjusting shot success helps a lot in doing this, because it points towards those days when a team has plenty of the ball, but just can't score.

Still here? You could definitely be forgiven for skipping ahead to this bit. Here are this weekend's predictions:




You can see the side effect I was talking about right at the start of this post, in the Newcastle win chance. Newcastle would have been predicted to lose anyway, but they also have below average stats for how many shots their opponents convert, so they get penalised very heavily now.

I have no doubt this percentage is a bit low, but it's happening because I use average performance to predict the result of single games. What the model's saying, I think, is that if Newcastle don't change their tactics against Man City from what they normally do (maybe 'park the bus'), they're going to get hammered.

The Swansea prediction also sticks out this week. Bit peculiar, but it would be no fun if we agreed with the bookies every time. Let's see what happens.

Lots more work still to do, but it's good to be making progress... Two big jobs on the list next:

1. As this blog points out, I really need to run the model over more seasons and see how it gets on.
It's a bit tricky because I use a stat on '% of passes in opponent's half' to model attacking pressure and that stat's only been available on the EPL Index site since this season. Overall it doesn't add huge amounts to the predictions though, so I'm probably just going to turn that feature off and then run over the past 3-4 seasons.

2. The model knows nothing about form at the moment - players perform better or worse depending on their opponents, but their base stats are the same in every game. I'm eyeing this as potentially the next big improvement.

Small bets placed and I'm off to enjoy the British countryside. With live score updates on my phone, obviously!

Friday, 15 March 2013

Football Sim: Predictions for 16/17 March 2013

Here we go again...

No big preamble this time, if you're reading this then you probably know where these forecasts come from by now (I like calling them forecasts, it sounds more scientific than predictions.) If you don't, have a read of these posts.

Here are the percentage chances for this week's games:



A few obviously stick out - Everton and Swansea to win are interesting, but I think both plausible (though maybe not at those percentages) and West Brom to beat Stoke, I'm not sure I trust because the model doesn't really seem to understand how Stoke get as many points as they do. Reasons for that are probably fairly obvious and to do with Stoke's style of play, but I haven't tried to deal with it yet.

And my betting choices:

Swansea v Arsenal - Home Win
Villa v QPR - Draw
Chelsea v West Ham - Home Win
Everton v Man City - Home Win
Tottenham v Fulham - Home Win
Southampton v Liverpool - Away Win
Man U v Reading - Home Win
Wigan v Newcastle - Draw
Stoke v West Brom - Away Win
Sunderland v Norwich - Draw

On the whole, the model's been running at around 50% of results called correctly and slowly making money through betting simple singles at the same stake on each prediction. Every time I try to mess about with that basic approach, it does worse, so I'm sticking to it for now.

I did make some improvements to the model this week, but overall it's made only a very small difference to accuracy, which was a bit disappointing. I may go for incorporating form next, rather than using each player's average stats across the whole season all the time, but it's going to a be a busy week at work so that may have to wait...

Same as last week, I might also tweet an update when the starting line-ups are confirmed - @data_monkey if you're interested. Although last week, the original predictions did marginally better than the update, due to Holt's penalty miss. Maybe go with these as they are!

Monday, 11 March 2013

Football Sim: 9/10 March performance review

The four fixtures played on Saturday seem to have been acknowledged by everybody on my Twitter feed as 'a bit tricky'. I placed small bets on each game again, not really to gamble but because it keeps me honest. If I'm forced to actually pick a result, then there's no making excuses afterwards and claiming the model did ok when it was poor, or that I'd really have gone for a draw in the end, not a home win. When you're only looking at percentage chances of a result, it's easy to convince yourself that some of the bad forecasts were random chance.

From Saturday's forecasts, I'm fairly happy with the percentages that the model turned out, with the exception of QPR. The bookies said QPR would win. Other models said it was close. My model said Sunderland would win.

When Sunderland scored first I was feeling pretty smug, but then QPR got three and that was that. I've only seen the highlights but it looked like QPR deserved it, so I'm going to do some diagnostics on that one and work out what went wrong.

I changed my mind on the predictions at the last minute, after re-running the sim with confirmed starting line-ups. This led to a switch from draws in Norwich v Southampton and West Brom v Swansea, to picking Norwich and Swansea wins for betting purposes (N.b. even though I picked Swansea for a bet, West Brom had the highest chance of winning that game.)

Overall, I had on Saturday:

Reading v Villa - Away Win - Won
QPR v Sunderland - Away Win - Lost
Norwich v Southampton - Home Win - Lost
West Brom v Swansea - Away Win - Lost

And on Sunday:

Liverpool v Tottenham - Home Win - Won
Newcastle v Stoke - Home Win - Won

50% correct, which is pretty much bang on the model's average. We were a missed penalty away from getting Norwich right too.

Betting with £10 stakes again, you'd be £3.30 up. Hardly setting the world on fire but a win's a win and that's wins two weeks in a row (four actually, but I didn't blog the first two so they don't count).

I'm going to spend some time with shot calibration this week, if I can find the time, and will try to post about that at some point. Goalscoring in the model is hard to get right, because there aren't that many historical goals per player to set the conversion chances. We see hundreds of passes every game, but only a couple of goals and the model is quite sensitive to the settings for each player's chance of a shot being a goal. I'm pretty sure there are some performance gains to be had here.

Saturday, 9 March 2013

Football Sim: Predictions for 9/10 March 2013

Looks like potentially a tricky set of fixtures to call this week as many are close to 'standard' home/away/draw percentages. If I get the chance, I'll re-post before 3.00 using the actual starting line-ups to simulate, but for now I've taken them from Fantasy Football Scout as usual.


We're fairly close to the market odds everywhere, with the exception of Sunderland, where my model is predicting an away win against QPR. Harry dropped Taarabt last week and Zamora may be coming back from injury so the QPR line-up is a little in doubt. Let's see if we can squeeze in that rerun of the model before kick off.

For betting, We've got some fairly clear over-indexes to pick (see last week for an explanation) and a couple of games where it's a toss-up between an away win and a draw.

Clear ones first:

Reading v Villa - Away Win
Liverpool v Tottenham - Home Win
Newcastle v Stoke - Home Win
QPR v Sunderland - Away Win

And the close calls:

Norwich v Southampton
West Brom v Swansea

I'm going for draws in those two, because it's an incredibly close call between draws and away wins and we'll get better odds on draws.

Neck stuck out. See you later!

Tuesday, 5 March 2013

Football Sim: 2/3/4 March performance review

We let the football sim loose properly this weekend, with percentage chance forecasts for each game and I stuck my neck out with betting choices too. How did it go?

Overall, seven out of ten. Literally! Seven out of ten results called correctly, which isn't too bad at all.

Admittedly it wasn't the most difficult week to predict, with the top sides mostly playing teams that they were expected to beat and those games running to form, but still, you can only beat what's in front of you. As the pundit said to the viewer.

Link to last week's percentage chances and predictions if you want to take a look.

If you want to use the model for betting - and Twitter is telling me that some of you definitely do! - then I was trialling a new method last week. The method picks results that are 'over-predicted', so if 25% of games  in the model are usually a draw and the model's prediction for a single game is a 30% chance of a draw, then there's a good chance that's what we'll be betting on.

What this method seems to do is steer the model towards predictions that aren't already priced into bookies odds. There's no point in betting on home wins unless they're over-predicted, because the odds are rubbish and you'll just slowly lose money. I've simulated betting just on the highest chance result and the latest version of the model would end a little down across the whole season so far. This new method, as well as allowing us to bet on draws (read last week's post for an explanation), also swings us towards betting on slightly more unlikely events, but ones that have better odds.

For betting purposes, I picked (not bothering to chase best odds)...


Man City's win last night completed the fixtures and with a £10 stake on each game (£100 total), you'd be up £26.30.

I've said before that the model overcooks Arsenal. It's very frustrating... although possibly more so if you're an Arsenal fan. The simulation is based to a large extent on passing and attack - it doesn't do glaring defensive errors yet. Maybe an indication that if Wenger could sort the Arsenal back four out, they'd be doing an awful lot better. Anybody reading who didn't already know that? Let's move on.

The other two results the model missed were predicted draws at Southampton and Stoke. Both missed by just one goal. For betting purposes, I'm happy with that because if you can call roughly one draw in three, you'll break even and this week, the correct call on Sunderland's draw covered the other two, plus a little extra.

Finally, here's something I'm quit excited about...

What would have happened if you'd followed this £10 betting pattern all season so far? Starting with 100 quid in the bank, you'd now have £380, not including this week's win. If you're thinking it looks slightly odd, this chart shows games being played one at a time, not in weekend blocks of ten.



Blimey.

I'm still not building this primarily as a betting model, but well, it's kind of hard to resist when the chart looks like that.

A couple of (potentially big) caveats in the interests of honesty. I'm still running the full season sim using player stats for the whole of this season. This means the model knows about things like Michu's, Bale's and Van Persie's goalscoring form before the bookies did. That's not strictly fair but from now on, I'm calling results before the event.

I also don't know when the odds that I have (from www.football-data.co.uk/englandm.php) were scraped. The model knows actual starting line-ups for each game and those odds may be from the day before kick-off, when injury niggles etc. were still in doubt.

More this weekend. Let's see what happens...

Friday, 1 March 2013

Football Sim: Predictions for 2/3/4 March 2013

Here we go. Actual predictions, before the event this time! Radical idea I know.

Should ensure the model's performance takes a nose-dive...


As usual, if you'd like to know how this is all done, click here and scroll though some past posts.

I get team line-ups from Fantasy Football Scout.

EPL Index provides all the player performance data.

Footballdata.co.uk provides past betting odds and game results.


I'm excited this week because I've managed to improve prediction accuracy in the model after a few false starts, where I thought I had, but it turned out to be programming bugs and/or random errors.

The model's now learned about opposition strength and it will modify the expected performance for each player's passing accuracy and number of touches, based on who they're playing against. It means for example that teams will find it much easier to pass the ball to their strikers and create scoring chances against QPR, than against Spurs.

Exactly how it does that I'll save for another day, but it's got regression models in it and I'm quite proud of the way it predicts! It's taken some serious effort to get working.

This is what the improvements have done to our cumulative prediction accuracy vs. the bookmakers over the season so far - how often the model's favourite wins vs. how often the bookmakers' favourite does. Green means the model was winning at that point in the season.


It's not a huge leap in performance, but we're fighting for every fraction of a percentage point improvement from here.

Enough methodology, here are this week's predictions.


Am I going to have a bet this week? Damn right I am. I've got a system. (This can only go well.)

Actually, running across the season so far, this principle would have worked extremely well. I'm going to pick results where the model thinks an event is more likely than usual. E.g. the model averages 23% of matches ending in a draw (bit low that, as I've mentioned before), so we'll bet on a draw if the draw prediction for a single game is significantly higher than 23%.

This has the immediate advantage that it allows us to bet on draws. As I've mentioned before, a draw is almost never the most likely single game outcome, but in total, 25-30% of games end in a draw. If you never bet on a draw, you'll definitely lose over a quarter of the time before you even start.

Overall, this method will call slightly fewer results right than just betting on the model's favourite. But. And it's a big But. It means we call far more long-shots correctly.

For this weekend's games, the new method gives...

Tottenham v Arsenal - Away win.
Villa v Man City - Away win
Chelsea v West Brom - Home win
Everton v Reading - Home win
Sunderland v Fulham - Draw
Wigan v Liverpool - Away win
Man U v Norwich - Home win
Swansea v Newcastle - Home win
Southampton v QPR - Draw
Stoke v West Ham - Draw

And we'll see how that lot turn out next week.

Monday, 25 February 2013

Curse Blogger post scheduler. Predictions for erm... last Saturday

This set of predictions was meant to go live on Saturday morning, but a glitch in Blogger's post scheduler meant it didn't happen, sorry about that. I had a very kind trail from @OptaPro on Twitter this week too, so it was an even bigger disappointment. On the plus side, I couldn't post manually because I'd gone paragliding and I love paragliding, it's even better than statistics and football matches.

Back to football and the model's new and improved so I thought it would be worth reposting these predictions and explaining what I've been up to.

If you'd like a bit of history, try my past posts. I'm using an agent-based model of football matches to try to predict results and as usual, predicted starting line-ups for the teams are from Fantasy Football Scout. At some point, I'll build an engine to scrape the actual announced line-ups half an hour before kick off and re-run the model automatically, but one step at a time...

The big improvement I've been working on, which has turned out to make a small overall improvement in prediction accuracy, is to allow players to have a good or bad game. Previously, each player always performed at their average level - so for example if their passing accuracy averages 80% they'll always pass at 80% accuracy - but now I use the standard deviation of each player's passing accuracy and sample from a normal distribution, to decide how a player will perform. What this means is (to pick a couple of random examples) a very consistent player like Paul Scholes will always pass well in the model. A player like Darren Bent will have passing accuracy that's all over the place, with some very good games and some very bad ones.

This "form" feature is random for the minute, although I have spotted some interesting relationships  in the data and I think to an extent it's predictable when players will have a bad game. Check out this tweet for an example. I've promised EPL Index (where all the data comes from) an article on this though so it will have to wait for a minute.

Onto the predictions! They were predictions, honest.


And how did we do this week?

I actually had a small bet on these and am up for the weekend already, with the Spurs game still to play, so it didn't go too badly. From here, I picked:

Fulham to win (won)
Newcastle to win (won)
Wigan to win (won)
Sunderland to win (lost)
Norwich and Everton to draw (lost)
Spurs to win (playing tonight)

Of the remaining games, I don't trust Arsenal in the model at the moment. They pass well and it's largely a passing-based sim, so it seems to overestimate their chances, although it called this result correctly (just about). Who trusts Arsenal to reliably get a result anyway? The model called Man City and Man United's results correctly, but the odds were rubbish so I left those two.

If Norwich hadn't been allowed to take that last corner, I'd have had an even better weekend! This model's not doing so badly, if I do say so myself. Definitely worth persevering with.

I promise faithfully, on my honour, to have predictions up before the next set of matches this weekend.

Saturday, 2 February 2013

Football Sim: Predictions for 2/3 Feb 13

This is probably going to be the last set of predictions before I put some proper time into improving the model. We know that on current performance, it's going to slowly lose money if you bet on it and that's not tremendously exciting. Improvements from here are much harder than building the simulator in the first place, but I've got a few promising ideas to follow up.

Populating the fixtures with expected starting line-ups is also a complete pain in the neck and takes far too long. I'm going to have to sort that out, because sometimes my Friday evenings are based around beer rather than football match modelling.

Having said that, putting this set of forecasts together has thrown up a few interesting effects and led to me tweaking the algorithm a little already.

Here's what we've got. Starting line-ups from Fantasy Football Scout.



A few of those percentages stick out as disagreeing with the bookies odd this morning. Taking those ones in order...

Everton vs. Aston Villa

Everton are predicted to win, sure, but the bookies give Villa almost no chance and my model thinks they could win it. Why does it think that?

The big reason (that we'll see again for the Man City game) is that the model doesn't really understand defending yet. It will penalise teams that have only average ball retention but which are above average at defending. Conversely for Villa, it doesn't know that their back line has shipped 46 goals so far this season. The model also currently sees a player like Fellaini as a striker with decent shooting accuracy and below average passing - it doesn't understand the physicality of his game.

It's far from perfect! I did say I was doing my development work in public. Anyway, on to...

Manchester City vs. Liverpool

I'm sure this is the defending factor again. Could happen though and maybe this prediction will make some Liverpool fans happy.

Reading vs. Sunderland

I like this one, it's interesting! I've got Reading at 10% (decimal odds 10.0). The bookies odds say they're going to win the game. What's that all about then?

Well first of all, the model's using player stats over the season so far, not just the past few games. Up until Christmas, Reading really weren't good, which drags their performance down.

The big question in this game though is what's going to happen with Adam Le Fondre? The sim doesn't do substitutes yet and he's not in Fantasy Football Scout's predicted starting line-up. We can't do super subs.

Without Le Fondre starting in the sim, Reading will struggle badly to score.

We've played the game 1000 times without him. Let's stick Le Fondre in for Guthrie, play it another 1000 times and see what happens. We'll be giving Le Fondre his super-sub stats over the whole game.


That's quite a difference! Sunderland still win it, mind.

Now let's hope the favourites don't let us down this time and we can do a little better than last Tuesday evening.

Tuesday, 29 January 2013

Football Sim: Predictions for 29-Jan-13

OK, here they are! The first time I've let the football simulator loose in public, on games that haven't actually been played yet. Sounds like a recipe for disaster to me, but let's do it anyway.

If you've got no idea what I'm talking about, read this first.



A few things to be aware of... (in other words, here are my get out clauses, terms and conditions, caveats, call them what you like...)

I got the teams' predicted starting line-ups here.

Your guess is as good as mine (or Fantasy Football Scout's) what Newcastle's starting line-up is going to be.

I've made the new NUFC Frenchmen into completely average players for the purposes of the sim. They might be better than that and they might be worse!

As per my big "season so far" post yesterday, the model calls winners correctly around 50% of the time on average. Follow my tips at your own risk...

It gets exact scores right, around 10% of the time.

Both of those mean that for betting, it seems to just about break even (but not quite). I'm working on it.

That Sunderland prediction looks a little too heavily skewed to a home win for my liking.

But I'm off to put a bet on it anyway.

Monday, 28 January 2013

Football prediction: Simulating the season so far

I've been working for a while on an agent-based simulation of football matches, to see how close it can get to predicting the real results of Premier League games.

Last week, I explained roughly what the model is and how it works.

This week, is the model any good? I'll be honest, I may have cherry picked that Chelsea result a little for the last post, but this will be a warts-and-all picture of how well the model predicts. Or how it would have predicted the season so far (with one important caveat that we'll come to in a while.)

One last thing before we get stuck in... The most obvious use of a model like this (if it works) is to gamble based on its predictions, but I'm building more for the technical challenge of seeing if I can do it. I'm really interested in using a model like this as a scenario planning tool - what would happen to your season if you signed player x? Or if player y got injured? If the model can be made to work, you could run 'what ifs' and work out the value of players in terms of expected points added to the team's total across a season.

Back to betting, I might have a punt, but I'm not really a gambler. Bet on it if you like (sensibly!) as I start to predict games on Wallpapering Fog and don't forget to add a comment to let us know how you got on. I'll talk about odds a fair bit below, because they're an obvious source of another prediction, to compare with the model. Having said that, if you'd bet on every game so far this season using the model's predictions - up to 20th January 2013 - you'd have just about broken even. Improvements to the model from here, would make it profitable. Got your attention? Here we go.

What I've been doing this weekend, is building some code to run a whole series of games in succession, not just one at a time. Then I fed in the fixtures, starting line-ups and player statistics for each game this season, up to the 20th January, using data from EPL Index. We simulate each individual game 100 times and get an overall predicted likelihood of home win, away win or draw, plus the most likely scoreline.

Remember that caveat I mentioned? Here it is. I'm simulating each player, using their average performance across the whole season so far, which isn't strictly fair. When Fulham played Norwich on the first day of the season, I wouldn't actually have had any 2012/2013 data to feed into the model at the time - only the previous season's numbers. It's something else on the long list of development tasks that need dealing with...

Here are the predictions anyway. Correct calls in green.
Google's determined to open the image below in its G+ gallery, which isn't readable. Here for bigger.



Overall, the model calls 50% of results correctly, on the criteria that the team it gave the most chance of winning, ran out as winners in real life.

I was initially a bit disappointed with that. Only 50%? I was hoping for more.

Then I had a look to see how often the bookies get it right. No doubt this will be incredibly obvious to some readers, but as I said I'm not a gambler. How often did the bookies' favourite win those games? 51%. (odds from football-data.co.uk)

Suddenly 50% doesn't seem all that bad!

A big part of the error comes from draws, both in my model and in the bookies' odds. A draw is almost never the most likely result of a single game, but overall, around 30% of games will end in a draw. My model only called one game as having a draw as the overall most likely outcome - Aston Villa vs. Stoke.

When you simulate game-by-game, you'll predict almost zero draws, which means you'll be wrong 30% of the time before you even start. Predicting a season, where you only simulate each game once would give a 'normal' number of draws, but each individual game's prediction would be much less accurate. It's swings and roundabouts, depending on whether we're trying to predict final league placings, or the result of a single game.

If you'd bet on the model's prediction for every game, using the same stake, at Bet365's odds, you'd have lost 3% of your money so far. If you'd taken the best odds available in the market each time, not just Bet365's, you'd actually be up 1%. That's not a disaster for a first effort! At least we're not ruined.

Let's see what that accuracy looks like. I tweeted this one over the weekend; it shows ten game rolling average prediction accuracy for the model and also for the bookies.


When the shaded area between the lines is red, the bookies are predicting more results correctly than the model, over the previous ten games. When it's green, the model is out-performing the bookies.

It's interesting that a couple of weeks into the season, accuracy for the model and for the bookies plummets to just 10-20%. It may be that the early season is harder to predict - we'll need to run a few more seasons to find out. That period certainly screws up any hopes of winning a fortune as the bookmakers do slightly better, even though both are doing badly.

Here's the same data, cumulatively. The chart shows total accuracy across the season so far, with 20th January on the far right hand side.


You can see that the bookies' favourites have won more often than the model's across the whole season so far, ending with just the 1% gap that I described earlier, 51% to 50%.

What's very interesting to me, is that the model looks like it's improving slowly across the season and closing the gap; the games may be becoming more predictable as the season goes on. I'm not jumping on that conclusion just yet, but I'm certainly going to keep an eye on it.

If you'd bet using the model, only since the New Year at best market odds, you'd currently be up 19% on your original stake.

Let's finish with the next big improvement for the model - at least I hope it will see a significant improvement in predictive power. I'm seeing these developments as positives, even though there's a fair bit of work involved in building them, because our simple view of the world is doing pretty reasonably and there's huge scope for improvement from here.

At the moment, once a team has the ball in the sim, the opposition can't win it back, the team in possession can only lose it. This is fine in a game against an 'average' team, but taking Arsenal as an example, their passing accuracy was 90% against Sunderland and 81% against Manchester City. I've got no doubt that Man City caused that to happen by harrying their opponents, so the model needs to account for it.

Even more important, it's not every player's passing accuracy that drops against higher quality opponents - some will cope much better than others. We need a way to predict what each individual player's passing accuracy will be, against this week's opponents. I'm working on it.

Stay tuned for predictions for Tuesday's games!

Monday, 21 January 2013

Simulating football matches: An experiment.

Prediction. The holy grail of analysis. Diagnostics are good and they help us to understand the past, but if we can't use that work to get better at predicting the future, then isn't it all a bit pointless? If your theory doesn't predict the future, then it isn't science. Unlike football punditry, you don't get meteorologists diagnosing that last weekend's weather was rubbish because "the Sun must have had an off day". Scientists test their theories through prediction.

In my day job, we predict advertising. You've run adverts for your business before, so we measure the effect of those and then we can tell you how much you'll sell in the future.

Advertising's mostly quite dull. Can we do it for football?

Since Moneyball, a lot of people have been paying close attention to football statistics, writing up analyses and discovering relationships in OPTA's football data. Man City are even trying to tap into those amateur insights through the MCFC Analytics Project.

I couldn't resist diving in, so armed with a subscription to EPL Index (four quid a month for player stats for each individual game? Yes, please) I've been running a little side project and playing with the data.

If you want to predict football, there are a few ways you could go about it and I did have a crack at this project years ago, but with only very top-line data on past game results. You can build a regression model (a bit like the advertising models I build for a living) that uses each team's form to predict the outcome of the next game.

It works something like this...

Predicted result = f(Home Team form, Away Team form, plus lots of other things like goal-scoring and conceding rates...)

All weighted for the quality of opposition over the past few games.

This type of model kind of works. Basically, it will predict things like Man U should beat Wigan, but we already know that. The model I built a few years ago didn't do any better than my own guesses and that's not tremendously useful.

Top-line models like this also have a massive issue in that there are simply too many variables that need to be accounted for. What are the chances that Man U beat Wigan if Van Persie's injured? Our model based purely on past form will struggle with that, especially if he's played all season and we've got no experience with him not present (and just as important, a different player playing) in the team.

You also get very little in the way of explanation with top-line models like this. Man U will win because they usually win and Wigan will lose because (sorry Wigan fans) they usually lose. What can Wigan do about that? Well obviously they need to improve their form. Thanks, Mr. Consultant, you're fired.

Long story short, we need a different technique and the one I've been using is called Agent Based Modelling (ABM).

ABM simulates the world from the bottom up rather than the top down, which in football means simulating the players rather than the result. We set up an artificial game - using real world OPTA statistics about the performance of individual players - and we run the game to find a predicted result. The result is an outcome of the simulation that we can't control directly.

If you're thinking, "Is he trying to build Football Manager using OPTA data?", that's basically the size of it, yes. Told you it was more fun than advertising.

Inside the model, you kick off the game and from then on, it's all down to the simulation. The player with the ball will make a decision, based on what they do most often in real games - pass, shoot, dribble... each decision is randomly generated, but weighted towards the probability of what that player does most often in real life, based on the OPTA data.

If they choose to pass, the simulation checks for a successful pass and then works out who the ball went to, again a randomly generated choice but weighted by real data. It's the same if they shoot, when we work out the chances that their shot went in. If they lose the ball, it transfers to a player on the opposition, again determined by a weighting of... you get the idea. Then the whole thing starts again with the player who has the ball now.

We play the game through, with players passing, shooting, losing the ball etc. and we get a result, which is our prediction for the match.

Now, you might say, "but there were loads of randomly generated decisions in the model. If we ran it twice we might get different results", and you'd be absolutely right. It's just like the real world and if the same teams play each other a few times, you can get a different result every time.

What we're after is the probability of winning for each team, so we run the match 1000 times (for now - it's a nice round number) and count up how many times each team wins.

After some teething problems (it wouldn't be interesting if it was too easy) the model's starting to turn up sensible results and I promise I'll share its predictions for the next set of Premier League games (29th and 30th Jan). I'm not standing by those predictions yet, but it will keep me honest and motivated to do the development in public and to an extent already has... after tweeting on Saturday that Norwich might have more chance against Liverpool than the bookies thought and then watching them get battered 5-0. I now know why the model did that and it doesn't do it any more!

The model is a huge oversimplification of a real game but over time, it should help to teach us about what's really important. As a quick example, the model currently doesn't treat crosses any differently from other passes - they're a complete or incomplete pass and that's it. If they're a complete pass, then the player who receives the ball might shoot. But if we keep seeing that teams with traditional wingers win more games than the model would predict, then that might need sorting out.

I'll end for today with a bit about the Chelsea vs. Arsenal game on Sunday, to illustrate what you get from the model and the sorts of things that we might be able to do with it. Here are the teams (no subs yet by the way):


Run that one 1000 times and what happens?

Chelsea:    44%
Arsenal:    26%
Draw:       30%

So Chelsea are predicted to win 44% of the time. We get a scoreline from the model too and here are the 15 most likely, adding up to 94% of all results. An interesting outcome is that although we predict Chelsea to win overall, the single most likely result is 1-1.


The actual result was 2-1 to Chelsea, so the model got the winner right and 2-1 was our third most likely score. That looks potentially ok! We'll only find out if it really works by testing across a lot of games though.

Another way to see if the predictions are sensible is to compare with the bookies' odds. There's probably something wrong if we're not in the same ball-park as professionals taking advantage of the wisdom of their crowds of punters. The bookies had these odds (decimal odds, with implied percentage in brackets):

Chelsea:    1.83 (55%)
Arsenal:    3.5 (29%)
Draw:       3.25 (31%)

On an Arsenal win, or a draw, we're almost bang on the market odds.  On Chelsea we're below, but bear in mind that the model's odds have to add up to 100%. The bookmakers' odds add up to 114%, which is why bookmakers make money.

Lastly, just as an example of what else you can do with this type of model, there were some raised eyebrows that Torres started for Chelsea instead of Demba Ba. What if they'd been switched and Ba had started the game? Let's run it another 1000 times...

Chelsea's chance of winning goes up by two percentage points to 46%.

Arsenal's chances go down, right? Wrong. This is why agent based models are good - they can show us things that we don't expect.

With Demba Ba starting for Chelsea, Arsenal's chances of winning actually go up by 1% to 27% (to complete the picture, the chances of a draw drop 3%). The balance of how often Ba receives the ball and how often he gives it away compared to Torres makes all the difference. All in all, the predictions barely move but it's an interesting outcome. We'll see more of these.

OK, that will do for now. Predictions next week and maybe, just maybe, a cheeky punt based on our forecasts.

Oh and if you're running your own project like this, I'd LOVE to hear about it! Stay tuned, this is just the start.

Monday, 9 February 2009

Sky, football and the back of an envelope (very UK-centric post warning!)

Sky has just won the rights to show five out of the six available Premiership football games packages from 2010, by bidding £1.62bn over three years . They're not allowed to bid for all six packages; the European Commission says so.

It's an interesting exercise to work out how much that means Sky think the football is worth to them. In 2006-2007, Sky made £4.1 billion in revenue (OFCOM) and the vast bulk of that (93%) came from subscriptions.

The first thing to say, is that Sky must think they'd lose subscribers if they lost the football. Of course they would.

Lets assume that Sky are trying to be profitable (because I'm an economist and economists like to pretend people are rational) and also that their margin is about 15%.

The 15% margin on £4.1bn means that Sky make something like £615m per year profit before tax, or 1.8bn over the three year life of the Premiership contract. That's very close to what they pay for the football - the price hasn't changed that much this time around (what's £100m between friends?) So if Sky could drop the football and all their subscribers stayed with them at the same price, they'd close to double their profit.

Or to put it another way, Sky are behaving as if live Premier League football makes up at least half of their business model.

That's not the whole story though. There's a longer term benefit of owning the football that comes from eliminating Setanta, which has been left with half the amount of football that it has at the moment. Setanta don't have much other than football to support their subscriber base and could be in a lot of trouble.

So now you know how football players can afford to insure (and then crash) £200,000 Ferraris. And don't be suprised if you see the European Commission taking an interest in the Premiership TV rights again in the next couple of years.


Update: Judging by their reaction to losing, Setanta really need that football.