pydfs-lineup-optimizer
pydfs-lineup-optimizer copied to clipboard
restrict TE in Flex
I tried restricting TE from the FLEX by using optimizer.set_players_with_same_position({'TE: 1}). It does not seem to work, I am loading a custom csv and creating list of players. I have attached the csv as excel file. NFL_op_input_20191215.xlsx
I'm facing the same issue. Would it be possible to get FLEX % distribution by position (i.e. TE - 20%, WR - 30%, RB - 50%)? Thanks for all that you do!
I would also like to say that selection Flex positions would be useful. I was trying to get that to work yesterday. As simple as Flex, use WR, use RB, use TE. Each is on or off. I am not sure a percentage is needed as that would be calculated from the optimizer but I guess it wouldn't hurt to also have exposure.
On Tue, Sep 15, 2020 at 10:55 AM hunterjohn22 [email protected] wrote:
I'm facing the same issue. Would it be possible to get FLEX % distribution by position (i.e. TE - 20%, WR - 30%, RB - 50%)? Thanks for all that you do!
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/DimaKudosh/pydfs-lineup-optimizer/issues/193#issuecomment-692770579, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQKFFZW5TVCY6JHGLMNCY3SF555VANCNFSM4RAOTMPA .
I'm also interested in this feature, right now I'm often having to turn one position type completely on or off as well. I think the ability to set a relative percentage for each position would be great, even if the optimizer only roughly followed the pattern.
you can remove the available positions from the settings file, run how many lineups you want then change it to WR or what ever and run more lineups since i havent figured out how to do it with coding yet
I would start with a simple question - why are you projecting TE (or some other position) to have scores that would allow them to land in your optimal lineup in the first place? If you are trying to build tournament lineups, the first approach would be to alter your projections to reflect the intuition that TE doesn't score enough points to win a large-field tournament. The easiest way to do this is to generate your lineups through multiple runs of the optimizer and apply a greater amount of jitter to positions like WR and RB than TE. I've posted some examples previously that show how to do this. Basically, you create a new pool of Player objects by randomly altering the existing Player objects according to your own criteria and then load them into the optimizer, generate lineups, then repeat the process again.
You can also do this as a post-optimization step. You have a couple of possible approaches: (1) Keep generating lineups until you hit the desired number that meet your criteria (in essence, throw out some "optimals") (2) Generate a large number of lineups and then use some genetic algorithm-like techniques to modify them
So, for option number 1, it would look like:
n_lineups_wanted = 150
lineups = []
# this is a generator so you can use a very large number without worry
for lineup in optimizer.optimize(10000):
# apply test criteria here
if test_criteria_met:
lineups.append(lineup)
if len(lineups) >= n_lineups_wanted:
break
Now you might say "I don't want to throw out optimal lineups" but you've already decided to throw out what the algorithm says is optimal with your exclusion criteria.
Option number 2 would look like the following
def mutate(lineups, players):
"""Make various changes to lineups"""
# mutation code here
return mutated_lineups
n_lineups_wanted = 150
lineups = list(optimizer.optimize(n_lineups_wanted))
mutated_lineups = mutate(lineups)
you can remove the available positions from the settings file, run how many lineups you want then change it to WR or what ever and run more lineups since i havent figured out how to do it with coding yet
I tried this by adjusting the uptake csv removing "/FLEX" from "TE/FLEX", but still got TEs in the FLEX albeit at a lesser exposure rate than normal. Is this the approach you meant?
Change
@SitesRegistry.register_settings
class DraftKingsFootballSettings(DraftKingsSettings):
sport = Sport.FOOTBALL
min_games = 2
positions = [
LineupPosition('QB', ('QB',)),
LineupPosition('RB', ('RB',)),
LineupPosition('RB', ('RB',)),
LineupPosition('WR', ('WR',)),
LineupPosition('WR', ('WR',)),
LineupPosition('WR', ('WR',)),
LineupPosition('TE', ('TE',)),
LineupPosition('FLEX', ('WR', 'RB', 'TE')),
LineupPosition('DST', ('DST',))
]
to
@SitesRegistry.register_settings
class DraftKingsFootballSettings(DraftKingsSettings):
sport = Sport.FOOTBALL
min_games = 2
positions = [
LineupPosition('QB', ('QB',)),
LineupPosition('RB', ('RB',)),
LineupPosition('RB', ('RB',)),
LineupPosition('WR', ('WR',)),
LineupPosition('WR', ('WR',)),
LineupPosition('WR', ('WR',)),
LineupPosition('TE', ('TE',)),
LineupPosition('FLEX', ('WR', 'RB')),
LineupPosition('DST', ('DST',))
]
or you can create new settings instead and use them when you call get_optimizer
@SitesRegistry.register_settings
class DraftKingsFootballNoTESettings(DraftKingsSettings):
sport = Sport.FOOTBALL
min_games = 2
positions = [
LineupPosition('QB', ('QB',)),
LineupPosition('RB', ('RB',)),
LineupPosition('RB', ('RB',)),
LineupPosition('WR', ('WR',)),
LineupPosition('WR', ('WR',)),
LineupPosition('WR', ('WR',)),
LineupPosition('TE', ('TE',)),
LineupPosition('FLEX', ('WR', 'RB')),
LineupPosition('DST', ('DST',))
]