wcrasta / ESPN-Fantasy-Basketball

Free Fantasy Basketball tools for ESPN Leagues
https://espnfantasy.warrencrasta.com
MIT License
31 stars 15 forks source link

updated season average methods #24

Closed richiehu17 closed 2 years ago

richiehu17 commented 2 years ago

Added a boolean variable that represents whether it's the regular season or not. If there are any matchups where the key playoffTierType is not equal to 'NONE', I'm assuming that means it's the playoffs.

If it's the regular season, use the current week. If it's the playoffs use the max regular season week.

Like I said in https://github.com/wcrasta/ESPN-Fantasy-Basketball/pull/23, I think it'd be a good idea to merge them as well. Unfortunately, I remember the bye weeks caused some issues with the averages, so I'd have to actually wait until fantasy playoffs again so I can see what the API data looks like again before doing that though.

richiehu17 commented 2 years ago

@wcrasta To expand upon the rankings, (I'm going to use the names I just looked up here: https://en.wikipedia.org/wiki/Ranking) for a weekly ranking I think your implementation of dense ranking works fine. The picture below that I also posted in the other PR was using your weekly dense ranking.

image

For a seasonal average, I think the fractional ranking is the best. I think in a seasonal average, INJ/DTD should be 12th for this week. Otherwise the weekly rankings are randomly skewed by how many ties there were that week. If one week had two teams tie for 2nd, the last place team will be 11th. If there were three teams tied for 2nd, the last place team will be 10th. I'd prefer if the last place team was always 12th.

That's also why I prefer the fractional ranking over the standard/modified competition ranking. It makes the weekly values more consistent when averaging across all of them. For a four player league with

  1. Player A
  2. Player B, Player C
  3. Player D

If we use fractional ranking (1, 2.5, 2.5, 4) we get a sum of 10 ranks. And every week using fractional ranking, regardless of how many ties and what ranks are tied, will always sum to 10 ranks, which I think gives the best consistency. All other ranking methods will give a different sum of ranks every week depending on number of ties.

wcrasta commented 2 years ago

Thanks for the detailed explanation @richiehu17. I'll aim to review the PR this weekend.

wcrasta commented 2 years ago

Thanks a lot for this PR. It looks good to me and hopefully this will work during playoffs as well.

I appreciate the clear explanation of rankings.

For a seasonal average, I think the fractional ranking is the best. I think in a seasonal average, INJ/DTD should be 12th for this week. Otherwise the weekly rankings are randomly skewed by how many ties there were that week.

That's a great point which I hadn't considered during my implementation of dense rankings. My goal was for the Avg. Weekly Opponent Rank value to be equal to the average of a team's opponent's weekly ranking across all weeks. However, I think your justification for a "seasonal average" makes a lot more sense.

wcrasta commented 2 years ago

@richiehu17 deployed! I'll also re-iterate how much I love the concept behind this feature. I'll definitely have to implement this for Yahoo leagues whenever I get some free time.