Data Science

Machine learning & data science for beginners and experts alike.
NickC
Alteryx Alumni (Retired)

Working for an American company I see lots of material posted around Baseball, Basketball and “Football” but being British I am a big follower of proper football.

 

If you are currently reading this you’re most likely trying to get a competitive edge on colleagues, friends, family playing Fantasy Premier League.  If not, don’t worry the concepts will be easily transferable to different versions or even sports.  If you are already bored by my spiel you can download the annotated workflow at the bottom of the post…

 

Image credit: www.premierleague.comImage credit: www.premierleague.com

 

First things first, connecting to the database, Fantasy Premier League has a free to use RESTFUL API which can be easily connected to from within Alteryx.  All you need is the URL (https://fantasy.premierleague.com/drf/bootstrap-static) and access to Alteryx Designer (free 14 day trial).  Using the download tool from within Alteryx you will extract all the latest information on each player, Number of Points, Goals, Assist, Yellow Card even their Current Form.  This will be returned in a JSON format so some parsing will be required to get into a more readable format.

 

The Optimization tool will be used to maximize the number of points a team can get within the constraints of the game.  It may seem daunting but hopefully this will educate you to some of the possibilities of using it.

 

Optimization tool.png

 

Input O – This is used to provide the names of the variables (Player Names) the coefficients (value you are trying to maximize (Points)).  You also have the option to include the upper and lower bounds which restrict the number of times a variable (Player Names) can be selected.

 

Input A – This provides the constraint matrix.  I have used the ‘Dense Matrix Variables in Rows’ which would require the constraints to become your column headers and the variables (Player Names) to go in each Row.

 

Variable

Players

Constraint

Striker

Constraint

Midfielder

Constraint

Crystal Palace

Constraint

Man United

Zlatan Ibrahimović 1 0 0 1
Wilfried Zaha (HERO) 0 1 1 0
Marcus Rashford 1 0 0 1

 

Input B – This is used to provide the direction and right hand side of the constraint.  The direction requires operators such as;  >=, ==, <=.  The right hand side is the constraint value.  An example might be, no more than 1 Man United Player and exactly 1 Midfielder so you would have a table like this.

 

Constraint

dir

Rhs

Man United

<=

1

Midfielder

==

1

 

Every constraint included in Input A must be included in the same order on Input B.

 

The Optimization tool will output the best selection of variables (Player Names) based on the highest number cumulative coefficient (Points) that meet your constraints.  For additional resources please see below:

My team got off to a shocking start, but has found its footing in the middle of the Alteryx UK league.  I have as of yesterday started to use my Alteryx workflow to push up the table, this started with a wildcard replacing the vast majority of my players.  My blinded faith in Crystal Palace players cost me, now I am shifting all my faith towards AAA, Alteryx Advanced Analytics.

 

Image credit: https://www.premierleague.com/players/4539/Wilfried-Zaha/overviewImage credit: https://www.premierleague.com/players/4539/Wilfried-Zaha/overview

 

Alteryx is being used by many the world’s largest football clubs – I’m not sure if I’m allowed to name any of them, so you will have to trust me.

 

My challenge to all you clever analysts is to build on this further!

  • Weighting on first XI and subs bench
  • Consider players that are injured
  • Consider upcoming fixtures
  • Captain Selection

Attached is a version 11 annotated workflow. So if you want to fully understand how it works please have a look at this.

 

Recording available here: https://pages.alteryx.com/UKI-FPL-Webinar-OW.html

 

 

Comments