League Analysis Tool
One of the early uses of what eventually became the Fantasy Math model was updating my leaguemates on everyone's projected scores and probability of winning throughout the week.
The model has come along way since then, but it's still one of the most entertaining use cases, especially if you have an active league, need some insight in your playoff chances, or want to evaluate your fellow owners decision making.
In the code, we look at all the matchups in my league for week 1 last year but you can easily adopt it to your own team to make it more interesting.
We start with information (which I put in a csv file and you can edit to reflect your own league) on everyone's starting lineup, along with info on who is playing who.
Using that and the projected point simulations from the Fantasy Math API, we'll write code that gives us everything we need to analyze our league for the week.
Results and Analysis Outputs
For a quick visual overview, we can plot every teams point distribution on one plot.
If that's too hard to see, we separate it out by matchup too.
Finally, we'll make a flexible tool that allows us to limit our analysis to only certain teams or positions. For example, here's the projected total RB scoring for all the teams in my division:
Detailed Matchup Analysis
We'll look at the league from a matchup perspective. What's everyone's win probability, over-under, betting lines, etc?
Working with the simulation API makes all this easy to figure out.
We'll also build a few helper functions that highlight various aspects of this table, e.g. the lock of the week (team with the best win probability), photo-finish, least exciting game etc.
Detailed Team Analysis
We'll also look at team specific stats. This is mainly a numerical representation of the plots above, but it highlights some interesting facets.
For example, how Joe's team has a much higher standard deviation (it's because 5/7 players came from two matchups and have highly correlated scores) than everyone else.
Our league pays out (and penalizes) for the high and low every week, so it's fun to look at each team's probability of getting both.
If you wanted, you could extend this to figure out probability of finishing in each spot (2nd high, 3rd high etc).
p_high p_low team nate 0.108 0.051 mike 0.096 0.049 sean 0.072 0.026 paul 0.005 0.298 andrew 0.075 0.061 steve 0.185 0.028 craig 0.108 0.049 alex 0.015 0.144 joe 0.115 0.055 ryne 0.056 0.082 mitch 0.074 0.071 jon 0.091 0.086
Past Results/Luck Analysis
With access to the model for 2020, you'll be able to do this analysis in advance of each weeks game. But it also can be interesting to look at past results to see how likely (or lucky) each team's performance actually was.
The metric in this case is easy: how likely was each teams performance? That is, how often did the simulations have the team the amount they did.
Here it is for the week and set of matchups we've been looking at:
If the model is accurate, we should expect this percentile to average around 0.50 (and indeed, this week the average and median percentiles are 0.539 and 0.501 — this model is good).
But an individual team is equally likely to be anywhere from 0-1.
You can see my (Nate) guys did a bit above average, in the 70th percentile.
Interestingly, the high for the week (Mitch) was a team the model didn't especially like, but who got a really good draw (95th percentile) from his distribution. And indeed, Mitch never got another high score the rest of the season.