Lineup Optimizer Part 3
How to Tweak the Optimizer for Your Own System
Starting Code as .ipynb (Jupyter Notebook)
If you haven't watched the previous videos creating the optimizer, please watch those first!!
-------FIRST VIDEO--------
https://youtu.be/zibV6xaOGEA
-------------------------------
-------SECOND VIDEO--------
https://youtu.be/Jb0dFugTneU
------------------------------
****NOTE****
Forgot to mention the simplest way to impact the optimizer, simply remove players you don't want from the player list prior to loading into the optimizer! This can ensure you don't incorporate a lot of injury designated players that may or may not end up playing, or avoid having a low minute bench player getting placed into tons of lineups due to a low salary situation.
*************
Hey everyone, welcome back! Today we are going to review a few ways to manually tweak the optimization process, while changing as little code as possible. These methods are primarily centered on altering the player list excel file prior to loading into the optimizer. This allows for unlimited customization, limited only by your own creativity. This can be removing players you are wary of, incorporating new metrics. The methods we are going to review today are as follows:
1. Implementing a Key Player parameter to enforce certain player selections.
2. Defining Studs and Value Plays to enforce certain player selections.
3. Implementing Ownership Percentages
1. Implementing a Key Player parameter to enforce certain player selections:
This is a fairly simple process that requires very little code rewrite. First we are going to want to open our player list in excel, and insert a new column. You can name this whatever you want, I have chosen to use the name KeyPlayer to make it easy to remember. We need to assign every player a value of 0 first off. The purpose of this is we are going to treat this value similarly to fantasy points, so we are going to sum the totals for the lineup and we need a number here to sum. Otherwise it will come through as what's known as a NaN in pandas, or Not a Number, and that doesn't player very nice with the optimizer. Next we are going to identify a handful of players we really like for the slate, and change that zero to a 1. Next, we need to SAVE our spreadsheet, so the most updated version gets loaded into the optimizer. Then once the variables are updated in the code, you will need to define how many key players you want to force into each lineup. Be wary of what positions and how many you choose, as you may accidentally force a broken rule. For instance, you pick 3 sg and a pg as a key player, then tell the optimizer all four of them need to be chosen. This will cause problems as it will challenge the position restraints.
2. Defining Studs and Value Plays to enforce certain player selections:
This process follows very closely to the key player process, so if you have skipped that section to learn this first, I recommend reviewing the key player process first. The difference is we will be bringing in 2 separate player designations, as sometimes you have some high scorers that you really like, and sometimes you have some high value players you want to incorporate, that may normally be ignored due to point projection. To do this, you will perform everything the same as in the key player method, just doubled up for a new field. 2 columns added in excel, bring in both to the pandas dataframe, then define 2 new variables for the optimizer specifying how many of each you want.
3. Implementing Ownership Percentages:
The process to add this into the spreadsheet and optimizer is the same, however you will need to think about this a little differently, as the goal isn't necessarily to minimize/maximize ownership projections, it's merely a piece of the puzzle that should be taken into consideration. You will want to structure this metric in a way that can functionally help the optimizer. The way I have shown is arguably a pretty poor method if implementation, but you are only limited by your creativity. You could use the ownership projections to drive your studs and values or key players designations, and not take the actual ownership metric directly into the optimizer.