Monday, August 01, 2011

Fantasy Football Optimization 2


So it turns out I was thick last post about picking the fantasy football team. As my friend Bren explained to me "you choose 11 players to be "on the pitch" each week, plus a captain who scores double (and a vice captain in case the captain doesn't play). can only have 1 keeper in the first 11, can choose any formation with a minimum of 3 defenders, 3 midfielders and 1 forward."

So the problem is now pick 11 players that will actually play and some really cheap players that won't

So whats the cheapest of each player you could get?
The cheaperst players in each position are about 4 or 4.5 each. For example
Goalkeeper
Moreira SWA 4.0 0
Defenders
Whitbread NOR 4.0 0
Tate SWA 4.0 0
Midfield
Lappin NOR 4.5 0
Gecov FUL 4.5 0
Allen SWA 4.5 0
Strikers
Miller WBA 4.5 6
Hulse QPR 4.5 0
Agyemang QPR 4.5 0

So if you picked from this price of player knowing they would not play that would allow you to spend more money on those that were on the pitch. Now defenders score less points than midfielders and strikers so lets say we only want three of them. And we then buy two cheap ones that we dont play. 2 cheap defenders costs 8 and one goalie for 4 means we now have 88 to pick the remaining 12 players. The case whether you should have 5 midfielders or 3 strikers is less clear. I will try both and see which has a higher score.

Attempt 1. Cheap goalie and 2 defenders and 1 midfielder. Cost 16.5 on 4 non playing players. Trying to have 3 strikers. The constraints would now be
num_goalkeepers <- 1
num_defenders <- 3
num_midfielders <- 4
num_strikers <- 3
max_team_cost <- 835
max_player_from_a_team <- 3

Gives a team of

1 Hart MCI GK 70 175
48 Ivanovic CHE DEF 70 144
49 Huth STO DEF 60 138
51 Hughes FUL DEF 50 129
197 Adam LIV MID 90 192
198 Malouda CHE MID 105 186
200 Dempsey FUL MID 85 168
201 N'Zogbia WIG MID 75 167
210 Jarvis WOL MID 60 133
386 Berbatov MUN STR 95 176
388 Odemwingie WBA STR 75 171

scoring 1779. You would make Adam your captain and he would have double points.

Attempt 2. Cheap non playing goalie and 2 defenders and 1 striker. Trying to have two strikers. Cost 16.5 on 4 non playing players.
num_goalkeepers <- 1
num_defenders <- 3
num_midfielders <- 5
num_strikers <- 2
max_team_cost <- 835
max_player_from_a_team <- 3

1 Hart MCI GK 70 175
48 Ivanovic CHE DEF 70 144
49 Huth STO DEF 60 138
51 Hughes FUL DEF 50 129
197 Adam LIV MID 90 192
198 Malouda CHE MID 105 186
200 Dempsey FUL MID 85 168
201 N'Zogbia WIG MID 75 167
210 Jarvis WOL MID 60 133
386 Berbatov MUN STR 95 176
388 Odemwingie WBA STR 75 171

with a score of 1769. Again Adam would be your captain. It looks like three strikers is a better plan than 5 midfielders. But it is a close run thing.

Just to make things really complicated Bren explained that you should generally have one good player on the subs bench in case one of the rest of the team is injured. "it's quite common for one of the main team to miss a week so you may need to make 1 sub an excellent player (probably defender since they're cheaper)". Having a defender as your good sub has the advantage that you are allowed to play with one forward and three midfielders so if one of your three forwards, four midfielders or three playing defenders gets injured a defender can sub in for any of those.

So assuming we actually want four defenders. We would have one cheap goalie and one cheap defender and one cheap midfielder. At a cost of 12.5 for non playing players.
num_goalkeepers <- 1
num_defenders <- 4
num_midfielders <- 4
num_strikers <- 3
max_team_cost <- 875
max_player_from_a_team <- 3

giving a team of


Player Club Pos Price Pts
1 Hart MCI GK 70 175
46 Cole A CHE DEF 75 150
49 Huth STO DEF 60 138
51 Hughes FUL DEF 50 129
54 Bardsley SUN DEF 50 123
197 Adam LIV MID 90 192
200 Dempsey FUL MID 85 168
201 N'Zogbia WIG MID 75 167
203 Downing LIV MID 85 163
386 Berbatov MUN STR 95 176
388 Odemwingie WBA STR 75 171
393 Davies K BOL STR 65 132


1884 points -123 as Bardley wont play = 1761. Basically Bardsley a Sunderland defender is really cheap at 5. This is one more than you pay for a player you don't want to play but if you do need to lay him he gets 123 points a season.
Davies looks a little low there with 132 points. The worst midfielder has 163 points. So what if we get rid of the third striker and try 5 midfielders?

num_goalkeepers <- 1
num_defenders <- 4
num_midfielders <- 5
num_strikers <- 2
max_team_cost <- 875
max_player_from_a_team <- 3


Player Club Pos Price Pts
1 Hart MCI GK 70 175
46 Cole A CHE DEF 75 150
49 Huth STO DEF 60 138
51 Hughes FUL DEF 50 129
53 Distin EVE DEF 55 124
197 Adam LIV MID 90 192
200 Dempsey FUL MID 85 168
201 N'Zogbia WIG MID 75 167
203 Downing LIV MID 85 163
210 Jarvis WOL MID 60 133
386 Berbatov MUN STR 95 176
388 Odemwingie WBA STR 75 171

1886-124 for Distin who usually wont play = 1762. So this is my best single fantasy football team of last season.

The more I learn about this game the more nuances it has. Off the top of my head
1. Model that the captain gets double points. In this case Adam the highest scoring player is actually quite cheap. But in the case where he was really expensive you would want to take into account that he can earn double points.
2. Take into account who teams are playing. With a full game by game scoring dataset you can investigate really interesting patterns like if playing top five club means less points and bottom five more. And if so make transfers based on upcoming games. This seems to be where a huge amount of the skill in fantasy football is.
3. Change the code so you can have 3->5 defenders, 3-5 midfielders and 1-3 strikers but only 11 total players.
4. Just picking cheap non playing players is probably wrong. You at least want to pick the best cheap players you can. Which I have not. I am told Shane Ferguson is a good buy so I will probably make him one of the cheap players.

If any of the intuitions about having a good substitute or any of my other assumptions are wrong please correct me.
If you predict different points for players this season. If you want to try this method for next season but dont want to run the program linked to in part one


1. Copy the dataset I have here
2. Put this data into a new google docs spreadsheet.
3. Make your predictions on the number of points they will score. So if you think Berbatov won't score 176 points this season but only 160 change that points value. You can delete players you are not interested in as well.
4. Put your new spreadsheet URL in the comments
and I will run a optimization over your predictions for you.

2 comments:

Cheese said...

One thing worth noting is that only a minority of players play the full season in any given year due to injuries, form and transfers. Points in season can be cross-referenced with points per game. Also, if a player has a period where they do not play, or indeed is new to the league, they are frequently undervalued by the market. Many optimize their team for last-season-score (either computationally or manually :-) ) and thus the players who have a high last-season-score (or during the season, season-points-to-date) are overvalued by the market due to high demand. I would always consider: form, points per game, score (total) and transfers (gameweek) when making transfers. Also eavesdropping in pubs helps.

live football scores said...

The bar cart is IT! Too perfect! Another amazing score! What we see all the first time we have learned the hard way not to break up are perfect! Looking caveman! It was a great weekend of football!