How to Build the Best Fantasy Football Team

Note 1: This is Part 1 of a two-part post on building fantasy league teams. Read this first and then read Part 2 here.

Note 2: Although the title says “Fantasy Football”, the model I describe below can, in principle, be modified to fit any fantasy league for any sport.

footballI’ve been recently approached by several people (some students, some friends) regarding the creation of optimal teams for fantasy football leagues. With the recent surge of betting sites like Fan Duel and Draft Kings, this has become a multi-million (or should I say, billion?) dollar industry. So I figured I’d write down a simple recipe to help everybody out. We’re about to use Prescriptive Analytics to bet on sports. Are you ready? Let’s do this! I’ll start with the math model and then show you how to make it all work using a spreadsheet.

The Rules

The fantasy football team rules state that a team must consist of:

  • 1 quarterback (QB)
  • 2 running backs (RB)
  • 3 wide receivers (WR)
  • 1 tight end (TE)
  • 1 kicker
  • 1 defense

Some leagues also have what’s called a “flex player”, which could be either a RB, WR, or TE. I’ll explain how to handle the flex player below. In addition, players have a cost and the person creating the team has a budget, call it B, to abide by (usually B is $50,000 or $60,000).

The Data

For each player i, we are given the cost mentioned above, call it c_i, and a point projection p_i. The latter is an estimate of how many points we expect that player to score in a given week or game. When it comes to the defense, although it doesn’t always score, there’s also a way to calculate points for it (e.g. points prevented). How do these point projections get calculated, you may ask? This is where Predictive Analytics come into play. It’s essentially forecasting. You look at past/recent performance, you look at the upcoming opponent, you look at players’ health, etc. There are web sites that provide you with these projections, or you can calculate your own. The more accurate you are at these predictions, the more likely you are to cash in on the bets. Here, we’ll take these numbers as given.

The Optimization Model

The main decisions to be made are simple: which players should be on our team? This can be modeled as a yes/no decision variable for each player. So let’s create a binary variable called x_i which can only take two values: it’s equal to the value 1 when player i is on our team, and it’s equal to the value zero when player i is not on our team. The value of i (the player ID) ranges from 1 to the total number of players available to us.

Our objective is to create a team with the largest possible aggregate value of projected points. That is, we want to maximize the sum of point projections of all players we include on the team. This formula looks like this:

\max \displaystyle \sum_{\text{all } i} p_i x_i

The formula above works because when a player is on the team (x_i=1), its p_i gets multiplied by one and is added to the sum, and when a player isn’t on the team (x_i=0) its p_i gets multiplied by zero and doesn’t get added to the final sum. The mechanism I just described is the main idea behind what makes all formulas in this model work. For example, if the point predictions for the first 3 players are 12, 20, and 10, the maximization function start as: \max 12x_1 + 20x_2 + 10x_3 + \cdots

The budget constraint can be written by saying that the sum of the costs of all players on our team has to be less than or equal to our budget B, like this:

\displaystyle \sum_{\text{all }i} c_i x_i \leq B

For example, if the first 3 players cost 9000, 8500, and 11000, and our budget is 60,000, the above formula would look like this: 9000x_1 + 8500x_2 + 11000x_3 + \cdots \leq 60000.

To enforce that the team has the right number of players in each position, we do it position by position. For example, to require that the team have one quarterback, we write:

\displaystyle \sum_{\text{all } i \text{ that are quarterbacks}} x_i = 1

To require that the team have two running backs and three wide receivers, we write:

\displaystyle \sum_{\text{all } i \text{ that are running backs}} x_i = 2

\displaystyle \sum_{\text{all } i \text{ that are wide receivers}} x_i = 3

The constraints for the remaining positions would be:

\displaystyle \sum_{\text{all } i \text{ that are tight ends}} x_i = 1

\displaystyle \sum_{\text{all } i \text{ that are kickers}} x_i = 1

\displaystyle \sum_{\text{all } i \text{ that are defenses}} x_i = 1

The Curious Case of the Flex Player

The flex player adds an interesting twist to this model. It’s a player that, if I understand correctly, takes the place of the kicker (meaning we would not have the kicker constraint above) and can be either a RB, WR, or TE. Therefore, right away, we have a new decision to make: what kind of player should the flex be? Let’s create three new yes/no variables to represent this decision: f_{\text{RB}}, f_{\text{WR}}, and f_{\text{TE}}. These variables mean, respectively: is the flex RB?, is the flex WR?, and is the flex TE? To indicate that only one of these things can be true, we write the constraint below:

f_{\text{RB}} + f_{\text{WR}} + f_{\text{TE}} = 1

In addition, having a flex player is equivalent to increasing the right-hand side of the constraints that count the number of RB, WR, and TE by one, but only for a single one of those constraints. We achieve this by changing these constraints from the format they had above to the following:

\displaystyle \sum_{\text{all } i \text{ that are running backs}} x_i = 2 + f_{\text{RB}}

\displaystyle \sum_{\text{all } i \text{ that are wide receivers}} x_i = 3 + f_{\text{WR}}

\displaystyle \sum_{\text{all } i \text{ that are tight ends}} x_i = 1 + f_{\text{TE}}

Note that because only one of the f variables can be equal to 1, only one of the three constraints above will have its right-hand side increased from its original value of 2, 3, or 1.

Other Potential Requirements

Due to personal preference, inside information, or other esoteric considerations, one might want to include other requirements in this model. For example, if I want the best team that includes player number 8 and excludes player number 22, I simply have to force the x variable of player 8 to be 1, and the x variable of player 22 to be zero. Another constraint that may come in handy is to say that if player 9 is on the team, then player 10 also has to be on the team. This is achieved by:

x_9 \leq x_{10}

If you wanted the opposite, that is if player 9 is on the team then player 10 is NOT on the team, you’d write:

x_9 + x_{10} \leq 1

Other conditions along these lines are also possible.

Putting It All Together

If you were patient enough to stick with me all the way through here, you’re eager to put this math to work. Let’s do it using Microsoft Excel. Start by downloading this spreadsheet and opening it on your computer. Here’s what it contains:

  • Column A: list of player names.
  • Column B: yes/no decisions for whether a player is on the team (these are the x variables that Excel Solver will compute for us).
  • Columns C through H: flags indicating whether or not a player is of a given type (0 = no, 1 = yes).
  • Columns I and J: the cost and point projections for each player.

Now scroll down so that you can see rows 144 through 150. The cells in column B are currently empty because we haven’t chosen which players to add to the team yet. But if those choices had been made (that is, if we had filled column B with 0’s and 1’s), multiplying column B with column C in a cell-wise fashion and adding it all up would tell you how many quarterbacks you have. I have included this multiplication in cell C144 using the SUMPRODUCT formula. In a similar fashion, cells D144:H144 calculate how many players of each kind we’d have once the cells in column B receive values. The calculations of total team cost and total projected points for the team are analogous to the previous calculations and also use the SUMPRODUCT formula (see cells I144 and J144). You can try picking some players by hand (putting 1’s in some cells of column B) to see how the values of the cells in row 144 will change.

If you now open the Excel Solver window (under the Data tab, if your Solver add-in is active), you’ll see that I already have the entire model set up for you. If you’ve never used Excel Solver before, the following two-part video will get you started with it: part 1 and part 2.

The objective cell is J144, and that’s what we want to maximize. The variables (a.k.a. changing cells) are the player selections in column B, plus the flex-player type decisions (cells D147:F147). The constraints say that: (1) the actual number of players of each type (C144:H144) are equal to the desired number of each type (C146:H146), (2) the total cost of the team (I144) doesn’t exceed the budget (I146), (3) the three flex-player binary variables add up to 1 (D150 = F150), and, (4) all variables in the problem are binary. (I set the required number of kickers in cell G146 to zero because we are using the flex-player option. If you can have both a flex player and a kicker, just type a 1 in cell G146.) If you click on the “Solve” button, you’ll see that the best answer is a team that costs exactly $50,000 and has a total projected point value of 78.3. Its flex player ended up being an RB.

This model is small enough that I can solve it with the free student version of Excel Solver (which comes by default with any Office installation). If you happen to have more players and your total variable count exceeds 200, the free solver won’t work. But don’t despair! There exists a great Solver add-in for Excel that is also free and has no size limit. It’s called OpenSolver, and it will work with the exact same setup I have here.

That’s it! If you have any questions or remarks, feel free to leave me a note in the comments below.

UPDATE: In a follow-up post, I explain how to model a few additional fantasy-league requirements that are not included in the model above.

Advertisements

18 Comments

Filed under Analytics, Applications, Integer Programming, Modeling, Motivation, Sports

We Are Hiring! Three Positions in Management Science

I’m excited to announce that my department at the University of Miami’s School of Business is hiring for 3 positions this year: two tenure-track, and one clinical track. Check out the descriptions below and spread the word!

Two Tenure-Track Faculty Positions in Management Science
School of Business Administration
University of Miami
Coral Gables, Florida, USA

The Management Science Department at the University of Miami’s School of Business Administration invites applications for two tenure-track faculty positions at the Assistant Professor level to begin in the Fall of 2016 subject to budgetary approval. Salaries are extremely competitive and commensurate with background and experience. Generous summer research support is anticipated from the School of Business.

Applicants with research interests in all areas of analytics will be considered. The Management Science Department consists of a diverse group of faculty with expertise in statistics and operations research. Duties will include research and teaching at both the graduate and undergraduate levels.

Applicants should possess, or be close to completing, a Ph.D. in statistics, operations research, or a related discipline by the start date of employment. Applications should be submitted by e-mail to MASrecruiting@bus.miami.edu, and should include the following: a curriculum vitae, up to three representative publications, brief research and teaching statements, an official graduate transcript, information about teaching experience and performance evaluations (if available), and three letters of recommendation. All applications completed by December 1, 2015 will receive full consideration, but candidates are urged to submit all required material as soon as possible. Applications will be accepted until the positions are filled.

The University of Miami offers a comprehensive benefits package including medical and dental benefits, tuition remission, vacation, paid holidays, and much more. The University of Miami is an Equal Opportunity/Affirmative Action Employer.

 

Clinical Faculty Position Opening For 2015-2016
Management Science Department
School of Business Administration
University of Miami
Coral Gables, Florida, USA

The School of Business Administration at the University of Miami is currently seeking applications for a non-tenure track Clinical faculty position in the Management Science Department to begin in the Fall of 2016 subject to budgetary approval. Salaries are extremely competitive and commensurate with background and experience.

Applicants with research interests in all areas of analytics will be considered. The Management Science Department consists of a diverse group of faculty with expertise in statistics and operations research. The Department offers a major/minor and has a Specialty Master Program in Business Analytics. The selected candidates will be expected to teach business analytics classes, supervise students’ projects, and contribute to program outreach efforts to establish/strengthen relationships with industry leaders in Business Analytics. They are also expected to be intellectually active and committed to career-long professional development. Writing and publishing are valued activities as means of disseminating knowledge.

Applicants should possess, or be close to completing, a Ph.D. in statistics, operations research, or a related discipline by the start date of employment. We are particularly interested in individuals who have extensive experience in areas related to business analytics such as data visualization, data mining, and machine learning. Candidates with a master’s degree and exceptional industry experience equivalent to a doctorate will be considered. Applications should be submitted by e-mail to MASrecruiting@bus.miami.edu, and should include the following: a curriculum vitae, brief research and teaching statements (for candidates from the academia) or a statement of professional achievement (for candidates from the industry), information about teaching experience and performance evaluations (if available), and three letters of recommendation. All applications completed by December 1, 2015 will receive full consideration, but candidates are urged to submit all required material as soon as possible. Applications will be accepted until the position is filled.

The University of Miami offers a comprehensive benefits package including medical and dental benefits, tuition remission, vacation, paid holidays, and much more. The University of Miami is an Equal Opportunity/Affirmative Action Employer.

Leave a comment

Filed under Uncategorized

Research Assistant Professor position at University of Miami’s School of Business

My department is hiring! :-) See details below.

The Management Science Department at the University of Miami’s School of Business Administration invites applications for a non-tenure-track Research Assistant Professor position to begin in the Fall of 2015. The Management Science Department is a diverse group of faculty with expertise in several areas within Operations Research and Analytics, including statistics and machine learning, optimization, simulation, and quality management. Duties will include research, teaching at both the graduate and undergraduate levels, and advising undergraduate students seeking majors/minors in Management Science or Business Analytics.

Applicants should possess a PhD in operations research or a related discipline by the start date of employment. Applications should be submitted by e-mail to facultyaffairs@bus.miami.edu, and should include the following: a curriculum vitae, up to three representative publications, brief research and teaching statements, an official graduate transcript, information about teaching experience and performance evaluations, and three letters of recommendation. Applications will be reviewed as they arrive. The position will remain open until filled.

The University of Miami offers a comprehensive benefits package including medical and dental benefits, tuition remission, vacation, paid holidays, and much more. The University of Miami is an Equal Opportunity/Affirmative Action Employer.

Leave a comment

Filed under Uncategorized

Tenure-Track Position in Big Data Analytics, University of Miami, School of Business

I’m very happy to announce that the School of Business at the University of Miami is hiring in my department! Details below. This is an exciting time to be involved in Business Analytics!

Tenure-Track Faculty Position in Management Science (Big Data Analytics)

The Management Science Department at the University of Miami’s School of Business Administration invites applications for a tenure-track faculty position at the junior or advanced Assistant Professor level to begin in the Fall of 2015. Exceptional candidates at higher ranks will be considered subject to additional approval from the administration. Salaries are extremely competitive and commensurate with background and experience. This is a nine-month appointment but generous summer research support is anticipated from the School of Business.

Applicants with research interests in all areas of Analytics will be considered, although primary consideration will be given to those with expertise in Big Data Analytics and the computational challenges of dealing with large data sets. Expertise in, or experience with, one or more of the following is particularly welcome: MapReduce/Hadoop, Mahout, Cassandra, cloud computing, mobile/wearable technologies, social media analytics, recommendation systems, data mining and machine learning, and text mining. The Management Science Department is a diverse group of faculty with expertise in several areas within Operations Research and Analytics, including statistics and machine learning, optimization, simulation, and quality management. Duties will include research and teaching at the graduate and undergraduate levels.

Applicants should possess, or be close to completing, a PhD in computer science, operations research, statistics, or a related discipline by the start date of employment. Applications should be submitted by e-mail to facultyaffairs@bus.miami.edu, and should include the following: a curriculum vitae, up to three representative publications, brief research and teaching statements, an official graduate transcript (for the junior Assistant Professor level), information about teaching experience and performance evaluations, and three letters of recommendation. All applications completed by December 1, 2014 will receive full consideration, but candidates are urged to submit all required material as soon as possible. Applications will be accepted until the position is filled.

The University of Miami offers a comprehensive benefits package including medical and dental benefits, tuition remission, vacation, paid holidays, and much more. The University of Miami is an Equal Opportunity/Affirmative Action Employer.

Leave a comment

Filed under Analytics

Removing Ligatures in HTML Files Generated from LaTeX Files

I recently had to convert a LaTeX document to HTML and, after looking into several alternatives, decided to go with htlatex. Because my document contains accented characters, I chose to use the UTF-8 encoding as that seems to be the trend. To convert a LaTeX source file called file.tex you can issue the command below, which will create two main files: file.css and file.html (warning: the space before -cunif is a must):

htlatex file.tex “xhtml,charset=utf-8″ ” -cunihtf -utf8″

Overall, I’m very happy with the results produced by htlatex. Nevertheless, as I loaded file.html on my iPhone, I noticed that mobile Safari does not render all ligatures properly. For example, it has no problem with the ‘fi’ ligature, but it displays a hollow square in place of the characters for ‘ff’ and ‘ffi’ ligatures. I have not tested other mobile browsers, so I’m not sure if this is only an issue with mobile Safari. Safari on my desktop computer does not exhibit this problem.

To be safe, I thought I’d be better off removing all ligatures from the HTML file, which led me to search around for their UTF-8 codes and to write a little command-shell script that uses Perl to perform the task. Since this might turn out to be useful to someone else out there, I decided to post my shell script here. Use it at your own risk and enjoy!

perl -pi -e ‘s/\xef\xac\x80/ff/g’ file.html
perl -pi -e ‘s/\xef\xac\x81/fi/g’ file.html
perl -pi -e ‘s/\xef\xac\x82/fl/g’ file.html
perl -pi -e ‘s/\xef\xac\x83/ffi/g’ file.html
perl -pi -e ‘s/\xef\xac\x84/ffl/g’ file.html
perl -pi -e ‘s/\xc5\x92/OE/g’ file.html
perl -pi -e ‘s/\xc5\x93/oe/g’ file.html
perl -pi -e ‘s/\xc3\x86/AE/g’ file.html
perl -pi -e ‘s/\xc3\xa6/ae/g’ file.html
perl -pi -e ‘s/\xef\xac\x86/st/g’ file.html
perl -pi -e ‘s/\xc4\xb2/IJ/g’ file.html
perl -pi -e ‘s/\xc4\xb3/ij/g’ file.html

By the way, I’m only concerned with Latin ligatures, but you can find UTF-8 codes for other ligatures on this page. Bonus: here’s another useful article related to this topic: The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!).

Leave a comment

Filed under Tips and Tricks

The First Sentence of the Great Analytics Novel

Thedarktower7 I’ve written many times before about the importance of promoting O.R. to the general public. One of the ideas that’s been suggested by several people is the possibility of writing a work of fiction whose main character (our hero) is an O.R./Analytics person. I still believe this is a great idea, if executed properly.

Today, my wife brought to my attention The Bulwer-Lytton Fiction Contest, which, according to their web page, consists of the following:

Since 1982 the English Department at San Jose State University has sponsored the Bulwer-Lytton Fiction Contest, a whimsical literary competition that challenges entrants to compose the opening sentence to the worst of all possible novels. The contest (hereafter referred to as the BLFC) was the brainchild (or Rosemary’s baby) of Professor Scott Rice, whose graduate school excavations unearthed the source of the line “It was a dark and stormy night.” Sentenced to write a seminar paper on a minor Victorian novelist, he chose the man with the funny hyphenated name, Edward George Bulwer-Lytton, who was best known for perpetrating The Last Days of PompeiiEugene AramRienziThe CaxtonsThe Coming Race, and – not least – Paul Clifford, whose famous opener has been plagiarized repeatedly by the cartoon beagle Snoopy. No less impressively, Lytton coined phrases that have become common parlance in our language: “the pen is mightier than the sword,” “the great unwashed,” and “the almighty dollar” (the latter from The Coming Race, now available from Broadview Press).

Just like an awful first sentence can be a good indicator of a terrible book, the converse can also be true. Take, for example, the first sentence of Stephen King’s The Dark Tower series, which I happen to be reading (and loving) as we speak:

The man in black fled across the desert, and the gunslinger followed.

It’s such a strong, mysterious, and captivating sentence…

…which brings me to the point of this post. If it’s going to be difficult to write The Great Analytics Novel, what if we start by thinking about what would be the perfect, most compelling sentence to start such a novel? Yes, I propose a contest. Let’s use our artistic abilities and suggest starting sentences. Feel free to add them as comments to this post. Who knows? Maybe someone will get inspired and start writing the novel.

Here’s mine:

Upon using the word “mathematical” he knew he had lost the battle for, despite the dramatic cost savings, their logical reasoning was instantly halted, like a snowshoe hare frozen in fear of its chief predator: the Canada lynx.

I can’t wait to read your submissions!

4 Comments

Filed under Analytics, Books, Challenge, INFORMS Public Information Committee, Motivation, Promoting OR

Semantic Typing: When Is It Not Enough To Say That X Is Integer?

Andre Cire, John Hooker, and I recently finished a paper on an interesting, and somewhat controversial, topic that relates to high-level modeling of optimization problems. The paper is entitled “Modeling with Metaconstraints and Semantic Typing of Variables“, and its current version can be downloaded from here.

Here’s the abstract:

Recent research in the area of hybrid optimization shows that the right combination of different technologies, which exploits their complementary strengths, simplifies modeling and speeds up computation significantly. A substantial share of these computational gains comes from better communicating problem structure to solvers. Metaconstraints, which can be simple (e.g. linear) or complex (e.g. global) constraints endowed with extra behavioral parameters, allow for such richer representation of problem structure. They do, nevertheless, come with their own share of complicating issues, one of which is the identification of relationships between auxiliary variables of distinct constraint relaxations. We propose the use of additional semantic information in the declaration of decision variables as a generic solution to this issue. We present a series of examples to illustrate our ideas over a wide variety of applications.

Optimization models typically declare a variable by giving it a name and a canonical type, such as real, integer, binary, or string. However, stating that variable x is integer does not indicate whether that integer is the ID of a machine, the start time of an operation, or a production quantity. In other words, variable declarations say little about what the variable means. In the paper, we argue that giving a more specific meaning to variables through semantic typing can be beneficial for a number of reasons. For example, let’s say you need an integer variable x_j to represent the machine assigned to job j. Instead of writing something like this in your modeling language (e.g. AMPL):

var x{j in jobs} integer;

it would be beneficial to have a language that allows you to write something like this

x[j] is which machine assign(job j);

To see why, take a look at the paper ;-)

Leave a comment

Filed under Modeling, Research