Closed kryptickevin closed 3 years ago
optimizer.add_players_group(PlayersGroup( players=[player for player in optimizer.players if player.projected_ownership <= 0.05], min_from_group=1, max_from_group=2, ))
how do u get that to work, ive tried this and heres the error i get:
TypeError: '<=' not supported between instances of 'NoneType' and 'float'
how is your projected_ownership field look like? .25 25%, how do you have it set up?
Can you show me your current Python script? It might be something else that is messing with this.
My column in my csv is named "Projected Ownership" and it is in decimal form, so 20% is .2.
On Thu, Sep 9, 2021, 6:45 PM lightninglarry @.***> wrote:
optimizer.add_players_group(PlayersGroup( players=[player for player in optimizer.players if player.projected_ownership <= 0.05], min_from_group=1, max_from_group=2, ))
how do u get that to work, ive tried this and heres the error i get:
TypeError: '<=' not supported between instances of 'NoneType' and 'float'
how is your projected_ownership field look like? .25 25%, how do you have it set up?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/DimaKudosh/pydfs-lineup-optimizer/issues/293#issuecomment-916490686, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARXSUG6CMQMRTN4LVJUVOM3UBE2H5ANCNFSM5DXKKSBA .
Where in your script is this block of code though? I only see this same block of code.
Copy and paste your whole python script, remove your custom stuff of you want.
from pydfs_lineup_optimizer import get_optimizer, Site, Sport, CSVLineupExporter from pydfs_lineup_optimizer.stacks import TeamStack, PositionsStack, PlayersGroup from pydfs_lineup_optimizer import AfterEachExposureStrategy
class CustomExporter(CSVLineupExporter): @staticmethod def render_player(player): result = f'{player.id}:{player.full_name}' if player.lineup_position != 'UTIL': result += f' - {player.lineup_position}' return result
optimizer = get_optimizer(Site.FANDUEL, Sport.FOOTBALL) optimizer.settings.csv_exporter = CustomExporter # replace default exporter with custom optimizer.load_players_from_csv(r"C:\Users\brand\Desktop\PYTHON\NFL\wk1\FanDuel-NFL-2021 ET-09 ET-12 ET-62415-players-list.csv")
optimizer.add_players_group(PlayersGroup( players=[player for player in optimizer.players if player.projected_ownership <= 0.05], min_from_group=1, max_from_group=2, ))
optimizer.add_stack(PositionsStack(['QB', 'WR', ('WR', 'TE')], for_teams=['MIN', 'ARI', 'BUF', 'CIN']))
optimizer.set_min_salary_cap(59500) optimizer.set_max_repeating_players(7) optimizer.restrict_positions_for_same_team(('QB', 'D'), ('RB', 'WR'),('RB', 'RB')) optimizer.force_positions_for_opposing_team(('QB', 'WR')) optimizer.restrict_positions_for_opposing_team(('RB'),('RB'))
lineups = optimizer.optimize(100 , max_exposure=0.50 , exposure_strategy=AfterEachExposureStrategy) for lineup in lineups: print(lineup) optimizer.export(r"C:\Users\brand\Desktop\PYTHON\NFL\NFLFANDUEL.csv") optimizer.print_statistic()
Can you confirm the name of your ownership column in your csv file is "Projected Ownership"? Can you also confirm that you have someone with less than 5% projected ownership? Change the min_from_group=1
to min_from_group=0
and see if it will run.
Can you confirm the name of your ownership column in your csv file is "Projected Ownership"? Can you also confirm that you have someone with less than 5% projected ownership? Change the
min_from_group=1
tomin_from_group=0
and see if it will run. @kryptickevin
still get same error when i change to your suggestion my field in csv is called projected_ownership with 22.5 in the field of csv representing 22.5%
TypeError Traceback (most recent call last)
I believe you are incorrectly naming your column in your csv. See this code:
@classmethod def get_player_extra(cls, row: Dict[str, str]) -> Dict[str, Any]: roster_order = row.get('Roster Order') fppg_floor = row.get('Projection Floor') fppg_ceil = row.get('Projection Ceil') return { 'max_exposure': cls._parse_percents(row.get('Max Exposure')), 'min_exposure': cls._parse_percents(row.get('Min Exposure')), 'roster_order': int(roster_order) if roster_order else None, 'projected_ownership': cls._parse_percents(row.get('Projected Ownership')), 'min_deviation': cls._parse_percents(row.get('Min Deviation')), 'max_deviation': cls._parse_percents(row.get('Max Deviation')), 'is_confirmed_starter': bool(row.get('Confirmed Starter')), 'fppg_floor': float(fppg_floor) if fppg_floor else None, 'fppg_ceil': float(fppg_ceil) if fppg_ceil else None, 'progressive_scale': cls._parse_percents(row.get('Progressive Scale')), }
It is looking for a column in your csv named "Projected Ownership" and you have named it "projected_ownership". Try switching it to "Projected Ownership" and see if it works for you.
@kryptickevin i think you are right, anyway you can email me to help me with something about this file?
larry.mcdonald002@gmail.com
Done.
Currently when using the following code from @DimaKudosh for constraining ownership in my lineups, I am only able to execute it successfully for one group.
optimizer.add_players_group(PlayersGroup( players=[player for player in optimizer.players if player.projected_ownership <= 0.05], min_from_group=1, max_from_group=2, ))
Ideally I would have 3-4 more of these groups with different ownership levels. How would I achieve this?