您好,
我第一次使用Scipy.optimize.linprog。
我的问题是:
我不知道如何使用代码,但这些是我想要优化的变量:
Date Salary Name Team y_pred
0 1 2 3 4
63 2017-12-02 8600 Andre Drummond 24 [0.134405]
219 2017-12-02 6900 Khris Middleton 22 [0.130379]
193 2017-12-02 11600 Giannis Ante 22 [0.121447]
133 2017-12-02 10400 DeMarcus Cousins 11 [0.119983]
30 2017-12-02 11400 LeBron James 4 [0.118579]
162 2017-12-02 7500 Devin Booker 15 [0.112879]
102 2017-12-02 7000 Jusuf Nurkic 6 [0.11069]
94 2017-12-02 6300 Brandon Ingram 16 [0.1035]
61 2017-12-02 8600 Nikola Jokic 9 [0.100618]
11 2017-12-02 6600 Lonzo Ball 16 [0.0972403]
64 2017-12-02 5900 Robert Covington 27 [0.0968286]
166 2017-12-02 8900 Damian Lillard 6 [0.0922509]
70 2017-12-02 7000 Spencer Dinwiddie 29 [0.0917086]
152 2017-12-02 7700 Kevin Love 4 [0.0909792]
83 2017-12-02 9900 Anthony Davis 11 [0.0860487]
88 2017-12-02 5000 Brook Lopez 16 [0.0854736]
25 2017-12-02 6000 Jrue Holiday 11 [0.085107]
190 2017-12-02 4900 Jordan Clarkson 16 [0.084582]
144 2017-12-02 7900 Marc Gasol 12 [0.0834062]
65 2017-12-02 9600 Ben Simmons 27 [0.0822223]
156 2017-12-02 3500 Jameer Nelson 11 [0.0813844]
36 2017-12-02 6000 Kent Bazemore 21 [0.0799453]
4 2017-12-02 4600 Alex Len 15 [0.0765753]
99 2017-12-02 5100 Julius Randle 16 [0.0755844]
73 2017-12-02 6400 Tobias Harris 24 [0.0739983]
我需要有8位玩家,最高工资总额为50,000。它应该由y_pred优化。
结果将是8位y_pred得分最高且保持在50,000以下的球员。
我能够使用以下代码导入linprog:
from scipy.optimize import linprog
我试过这个,但是,我又不熟悉代码:
optimize.linprog(y_pred, nba2017test['DK Sal'], bounds=(0, 50000))
我收到以下错误:
all the input array dimensions except for the concatenation axis must match exactly
更新
发现这段代码与我尝试做的完美配合(获得DraftKings阵容中的8位最佳玩家):
from pydfs_lineup_optimizer import Site, Sport, get_optimizer
optimizer = get_optimizer(Site.DRAFTKINGS, Sport.BASKETBALL)
optimizer.load_players_from_CSV("name of csv")
lineup_generator = optimizer.optimize(8)
for lineup in lineup_generator:
print(lineup)