Ikestrman / 9InningsPickEm

0 stars 0 forks source link

Poll options not including all top matchups #1

Open Ikestrman opened 2 years ago

Ikestrman commented 2 years ago

Using Apr. 18 as an example (captured the night before), not all matchup options are being included in the poll as expected. Here were the "top ten" matchups:

Athletics over Orioles - 67/33
Dodgers over Braves - 64/36
Padres over Reds - 63/37
Brewers over Pirates - 61/39
Red Sox over Twins - 57/43
Rays over Cubs - 56/44
Phillies over Rockies - 55/45
White Sox over Guardians - 49/51
Giants over Mets - 48/52
Diamondbacks over Nationals - 46/54

The first 7 are correct, but there's another 55/45 matchup that should be shown after that (Astros over Angels), and the last three should certainly be the other way around. Copy of the .csv as of today for later investigation:

2022-04-18 2022 0 LAD ATL 1582.072739 1546.130628 5.85418E-01 4.14582E-01 1587.485922 1547.772542 Clayton Kershaw Huascar Ynoa 57.45296007 49.87063999 14.57063995 -17.89381319 6.36978E-01 3.63022E-01 2022-04-18 2022 0 SDP CIN 1501.135403 1492.343142 5.47052E-01 4.52948E-01 1531.413826 1492.117373 Sean Manaea Nick Lodolo 55.16306652 45.68155805 10.26590975 -17.40130299 6.30009E-01 3.69991E-01 2022-04-18 2022 0 OAK BAL 1523.767041 1444.270176 6.44689E-01 3.55311E-01 1464.140459 1430.331344 Frankie Montas Spenser Watkins 56.98275778 41.79613275 35.98615193 -30.95830479 6.72336E-01 3.27664E-01 2022-04-18 2022 0 COL PHI 1499.710197 1496.391622 5.39234E-01 4.60766E-01 1469.844495 1515.676164 Chad Kuhl Aaron Nola 49.00026253 54.52639993 -12.44357149 1.079821928 4.54596E-01 5.45404E-01 2022-04-18 2022 0 HOU ANA 1543.493166 1491.101708 6.08198E-01 3.91802E-01 1542.803201 1518.920445 Luis Garcia Michael Lorenzen 52.47929083 51.39753153 -3.04866236 5.426334149 5.53721E-01 4.46279E-01 2022-04-18 2022 0 MIL PIT 1517.189212 1460.306361 6.14342E-01 3.85658E-01 1535.009413 1449.037555 Eric Lauer Zach Thompson 52.4349571 49.69494039 -13.6285616 18.15332544 6.13904E-01 3.86096E-01 2022-04-18 2022 0 CHC TBD 1477.173105 1544.10753 4.38525E-01 5.61475E-01 1482.821568 1526.861643 Kyle Hendricks Shane McClanahan 48.14112459 54.51986523 -6.814461793 15.74119188 4.35614E-01 5.64386E-01 2022-04-18 2022 0 NYM SFG 1507.801921 1562.747346 4.55583E-01 5.44417E-01 1528.500284 1526.771124 Tylor Megill Alex Cobb 50.47110095 52.3734849 -26.6432421 -11.70606295 5.18842E-01 4.81158E-01 2022-04-18 2022 0 WSN ARI 1471.547111 1453.538238 5.60163E-01 4.39837E-01 1466.705891 1455.112006 Josiah Gray Madison Bumgarner 47.84532735 50.39743303 -3.005740465 2.557994755 5.43195E-01 4.56805E-01 2022-04-18 2022 0 CLE CHW 1505.190335 1524.982493 5.06055E-01 4.93945E-01 1495.327659 1542.775973 Triston McKenzie Dallas Keuchel 52.61991685 45.58399093 -3.834279056 -30.95235593 5.08297E-01 4.91703E-01 2022-04-18 2022 0 BOS MIN 1527.212643 1487.944858 5.90056E-01 4.09944E-01 1532.516646 1509.213609 Rich Hill Dylan Bundy 52.62987386 49.65587656 -3.952222741 -3.453352602 5.66952E-01 4.33048E-01

Ikestrman commented 2 years ago

After further investigation, it appears this is expected based on how I've configured lines #296-313 of the Primary Script, as it takes the 5 largest values in each category (heaviest home "favorites" and heaviest away "favorites") before sorting and combining for the poll options.

As we see in this case, there were quite a few home favorites, and only two away favorites (the Rays and Phillies), so the "5 heaviest away favorites" included 3 games where the away team was actually the underdog (the White Sox, Giants, and Diamondbacks).

I can potentially refactor this to do the combination before finding the largest values (may take some time since it's converted to a list midway through for processing), but for now I have simply implemented a workaround (heroku release v15) increasing the favorites numbers to 7 and 7 for each frame, which will at least give 7 poll options before there's a chance for underdogs being listed (unless there are very few games that day, in which case non-favorites would still need to be listed (which is why a >50% floor would not be a sufficient fix)).