You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm digging into the code a bit, and trying to optimize using local projections:
from pydfs_lineup_optimizer import get_optimizer, Site, Sport, Player
import pandas as pd
player_ids = pd.read_csv('../dk_data/player_ids.csv')
projections = pd.read_csv('../dk_data/projections.csv')
projections = projections[projections['Fpts'] >= 10]
optimizer = get_optimizer(Site.DRAFTKINGS, Sport.BASKETBALL)
def row_to_player(row):
player_pos = [pos for pos in player_ids.loc[player_ids['Name'] ==
row['Name']]['Roster Position'].item().split('/')]
player_pos.remove('UTIL')
player = Player(
player_id=player_ids.loc[player_ids['Name']
== row['Name']]['ID'].item(),
first_name=row['Name'].split(' ')[0],
last_name=row['Name'].split(' ')[1],
positions=player_pos, # player_pos = ['PG', 'SG', 'G'] for example
team=row['Team'],
salary=float(row['Salary'].replace(',', '')),
fppg=row['Fpts'],
)
return player
players = projections.apply(row_to_player, axis=1)
optimizer.player_pool.load_players(players)
lineups = list(optimizer.optimize(10))
optimizer.export('result.csv')
And I'm met with the following error:
Traceback (most recent call last):
File "D:\Repositories\NBA-DFS-Tools\src\optimizer.py", line 37, in <module>
lineups = list(optimizer.optimize(10))
File "C:\Users\seans\AppData\Roaming\Python\Python310\site-packages\pydfs_lineup_optimizer\lineup_optimizer.py", line 463, in optimize
lineup = self._build_lineup(lineup_players, context)
File "C:\Users\seans\AppData\Roaming\Python\Python310\site-packages\pydfs_lineup_optimizer\lineup_optimizer.py", line 584, in _build_lineup
players_with_positions = link_players_with_positions(
File "C:\Users\seans\AppData\Roaming\Python\Python310\site-packages\pydfs_lineup_optimizer\utils.py", line 113, in link_players_with_positions
raise LineupOptimizerException('Unable to build lineup')
pydfs_lineup_optimizer.exceptions.LineupOptimizerException: Unable to build lineu
I've looked into the file and added a print statement on line 568 in lineup_optimizer.py right at the initial part of the def _build_lineup() function. This outputs a lineup result: [Dario Saric C/F/PF (PHX), Duane Washington G/PG/SG (PHX), Hamidou Diallo F/G/SF/SG (DET), Jimmy Butler F/PF (MIA), Jock Landale C (PHX), Joel Embiid C (PHI), Luka Doncic G/PG (DAL), Orlando Robinson C (MIA)]
Obviously this result is infeasible due to the fact that htere are 3 Center-only positions (Landale, Embiid, Robinson), and thus _build_lineup() is unable to fit them all in a normal roster and raises the Exception.
What could be causing this issue that this lineup was produced by the optimizer? Is my input data wrong? Are the opto rules wrong?
I'm digging into the code a bit, and trying to optimize using local projections:
And I'm met with the following error:
I've looked into the file and added a print statement on line 568 in
lineup_optimizer.py
right at the initial part of thedef _build_lineup()
function. This outputs a lineup result:[Dario Saric C/F/PF (PHX), Duane Washington G/PG/SG (PHX), Hamidou Diallo F/G/SF/SG (DET), Jimmy Butler F/PF (MIA), Jock Landale C (PHX), Joel Embiid C (PHI), Luka Doncic G/PG (DAL), Orlando Robinson C (MIA)]
Obviously this result is infeasible due to the fact that htere are 3 Center-only positions (Landale, Embiid, Robinson), and thus
_build_lineup()
is unable to fit them all in a normal roster and raises the Exception.What could be causing this issue that this lineup was produced by the optimizer? Is my input data wrong? Are the opto rules wrong?
here are the files im using: https://gist.github.com/chanzer0/f787c126e42c10d094b94d30863797a4
The text was updated successfully, but these errors were encountered: