Any ideas on how to balance max exposure when inputs exceed 100% available?
Let's say I screw up and want 30% of QB1, 40% of QB2, 20% of QB3, and 25% of QB4. As of right now the optimizer will throw an error as this lineup is indeed impossible since we have over 100% ownership of a QB.
Any ideas on how to tweak this input so if I do exceed 100% in my CSV file by accident, my goal is to have my intent be recognized by code and inputted to optimizer as a percentage of 100% instead of 115%.
I am trying to avoid the error. My intent is to take 30%+40%+20%+25% or 115% and its percentage of 100% so the optimizer sees 26%, 34%, 18%, and 22%. The errors make me cringe and its because of my manual mistakes every time, but trying to figure out how to prevent this error, by taking the total minimum ownership of each position and dividing it by the total possible amount allowed at that position. With a QB that would be 100%. A running back 200%...etc.
It would be nice to have some way to take the total of the minownership percentage, figure out a way to bring that total under 100%/200% etc so if I enter the wrong data in the CSV I don't constantly get 'Lineup Error'.
I believe everyone has this issue and haven't found a fix
On Tue, Nov 17, 2020, 1:14 AM bigboyz [email protected] wrote:
Let's say I screw up and want 30% of QB1, 40% of QB2, 20% of QB3, and 25% of QB4. As of right now the optimizer will throw an error as this lineup is indeed impossible since we have over 100% ownership of a QB.
Any ideas on how to tweak this input so if I do exceed 100% in my CSV file by accident, my goal is to have my intent be recognized by code and inputted to optimizer as a percentage of 100% instead of 115%.
I am trying to avoid the error. My intent is to take 30%+40%+20%+25% or 115% and its percentage of 100% so the optimizer sees 26%, 34%, 18%, and 22%. The errors make me cringe and its because of my manual mistakes every time, but trying to figure out how to prevent this error, by taking the total minimum ownership of each position and dividing it by the total possible amount allowed at that position. With a QB that would be 100%. A running back 200%...etc.
It would be nice to have some way to take the total of the minownership percentage, figure out a way to bring that total under 100%/200% etc so if I enter the wrong data in the CSV I don't constantly get 'Lineup Error'.
— 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/220, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANBWO7QTW5JCPTO3XWVPOYDSQIIELANCNFSM4TYD7MDA .
Wouldn't the easiest way be to just create a helper sheet in Excel with a simple formula to calculate this for you?
I would load the players using load_players rather than load_player_from_csv. This allows you to preprocess data to your heart's content. So, here, it could look like the following:
import pandas as pd
from pydfs_lineup_optimizer import get_optimizer, SITE, SPORT
o = get_optimizer(site=SITE..., sport=SPORT...)
# assume csv file has the following fields:
# player, pos, team, salary, fppg, min_exposure
def row_to_player(self, row):
"""Converts dataframe row to Player object
Args:
row (namedtuple): dataframe row
Returns:
Player
"""
valid_kwargs = (
'is_injured', 'max_exposure', 'min_exposure',
'projected_ownership', 'game_info', 'roster_order',
'min_deviation', 'max_deviation', 'is_confirmed_starter',
'fppg_floor', 'fppg_ceil'
)
kwargs = {field: getattr(row, field) for field in row._fields
if field in valid_kwargs}
return Player (
player_id=row.player,
first_name=self._first_name(row.player),
last_name=self._last_name(row.player),
positions=[row.pos],
team=row.team,
salary=row.salary,
fppg=row.proj,
**kwargs
)
df = pd.read_csv('myprojections.csv')
df['min_exposure'] = df['min_exposure'] / df['min_exposure'].sum()
players = df.apply(row_to_player, axis=1)
o.load_players(players)