## 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
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 <- 1num_defenders <- 3num_midfielders <- 4num_strikers <- 3max_team_cost <- 835max_player_from_a_team <- 3 `

Gives a team of
`1         Hart  MCI  GK    70 17548    Ivanovic  CHE DEF    70 14449        Huth  STO DEF    60 13851      Hughes  FUL DEF    50 129197       Adam  LIV MID    90 192198    Malouda  CHE MID   105 186200    Dempsey  FUL MID    85 168201   N'Zogbia  WIG MID    75 167210     Jarvis  WOL MID    60 133386   Berbatov  MUN STR    95 176388 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 <- 1num_defenders <- 3num_midfielders <- 5num_strikers <- 2max_team_cost <- 835max_player_from_a_team <- 3 `
`1         Hart  MCI  GK    70 17548    Ivanovic  CHE DEF    70 14449        Huth  STO DEF    60 13851      Hughes  FUL DEF    50 129197       Adam  LIV MID    90 192198    Malouda  CHE MID   105 186200    Dempsey  FUL MID    85 168201   N'Zogbia  WIG MID    75 167210     Jarvis  WOL MID    60 133386   Berbatov  MUN STR    95 176388 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 <- 1num_defenders <- 4num_midfielders <- 4num_strikers <- 3max_team_cost <- 875max_player_from_a_team <- 3 `

giving a team of

`         Player Club Pos Price Pts1         Hart  MCI  GK    70 17546      Cole A  CHE DEF    75 15049        Huth  STO DEF    60 13851      Hughes  FUL DEF    50 12954    Bardsley  SUN DEF    50 123197       Adam  LIV MID    90 192200    Dempsey  FUL MID    85 168201   N'Zogbia  WIG MID    75 167203    Downing  LIV MID    85 163386   Berbatov  MUN STR    95 176388 Odemwingie  WBA STR    75 171393   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 <- 1num_defenders <- 4num_midfielders <- 5num_strikers <- 2max_team_cost <- 875max_player_from_a_team <- 3 `

`   Player Club Pos Price Pts1         Hart  MCI  GK    70 17546      Cole A  CHE DEF    75 15049        Huth  STO DEF    60 13851      Hughes  FUL DEF    50 12953      Distin  EVE DEF    55 124197       Adam  LIV MID    90 192200    Dempsey  FUL MID    85 168201   N'Zogbia  WIG MID    75 167203    Downing  LIV MID    85 163210     Jarvis  WOL MID    60 133386   Berbatov  MUN STR    95 176388 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.

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