Hacker News new | past | comments | ask | show | jobs | submit login
Win your fantasy league using operations research (alexmolas.com)
167 points by alexmolas 6 months ago | hide | past | favorite | 55 comments



I've used similar approaches to play sports fantasy games (casually) since 2009. Using LP solvers like this team selection games, and an ELO+regression approach for score/margin prediction games. Mostly as a way to beat friends while spending little or no time following the actual competition.

For team selection games the LP approach works great but does not dominate, as described in the OP. I've found it to work less well over the years and I wouldn't be surprised if the fantasy game vendors have been explicitly adding countermeasures - things like temporary wildcards, round-specific rules, trading limits and velocities, etc all mess with your LP constraints. Not that you couldn't also code that up but it's time consuming. You end up needing to follow the competition closely anyway and using your model as an advisor to spot "good deals" in the data.

edit: a few times I have also back tested my models vs the odds offered by the bookies (for the margin prediction games). Unsurprisingly the bookies have better models than me. Could be just using the bookies odds as the pick is a better approach.


I'm not sure if the article is tongue in cheek, but almost all of the skill and almost all of the noise in these games usually comes from your choice of value function, i.e. your ability to predict how many points a player will get in a given week.

Picking the best team subject to the constraints is trivial in comparison and you can solve the knapsack problem by eye, or with some kind of greedy/beam search approach.

This is different from the financial markets where almost all of the alpha (outperformance of one stock over another) has been taken away by other market participants, so a lot of professional time is spent on risk management, portfolio optimization, etc.


Generally incorrect. The critical thing here is that many player scores are correlated. Various configurations will have a lot more swing to their outcomes, and when you only care about being the number one spot, highest expected value probably won’t win it.


Player value correlation is indeed a thing. So too match ups in the next game, player playing out of position, etc. I haven't experimented but you are probably right that a model that could use factors like these effectively would outperform what I described.

But they aren't critical to building a model that will beat your mates and land you on the single-digits top%.


This is something I’ve been trying to find a way to account for in my fantasy drafting the last few years, after trying to maximize expected value has not gotten me the desired results (probably also due in part to the delta between expected and actual value). It’s occurred to me that a “boom or bust” lineup that scores +2 st dev one week and -2 the next is way better than one that performs +1 every week (hand waving exact values).


Build a correlation matrix between player positions and teams. Add a constraint the forbids the solution from having negative correlations below X.

The way you would want to test it is take the top 500 solutions from each approach and see how many of them are winners under whatever framework you care about.


The value function is crucial, sure. But back testing over a couple seasons I can usually land on something much better than what I as a (usually pretty casual) fan has in my head.

From an automation perspective the harder problem is getting match day squad selections (some sports regularly announce last minute teams, like at the time of the toss) and accounting for whatever special cases the game rules have tossed in (e.g. select a captain and vc, special reduced fees on trades this round, etc).

And to really win these games, rather say just beating your friends and landing top 5% globally, you also need risk management and portfolio optimisation strategies: e.g. when to play your "captain scores double this round" card? everyone has Mbappe, do you also pick him to hedge your riskier picks? I have no doubt that some players have built all this automation but I sure haven't.


If you want to maximize your chances of winning a very large game like this, you need to play quite a lot riskier than is intuitive, you definitely do not want to pick a popular player if your model predicts someone else will outperform him.

If you want to finish top 5%, having the best model should do it, with some attention to risk management in the last few games of the season (play riskier if you are in the 90th percentile than in the 99th).

If you want to maximise your chance of beating your friends, have the best model and think a little game theory at the end of the season based on whether you are leading or chasing.


I don't have the numbers to back this opinion, but I believe that consistently ranking in the top 5% in all the games will greatly increase your chances of winning the league. It's not necessary to win every stage, but just having high scores consistently will likely make you win the league.


I also don't have numbers, but I'd opine that you need that (top 5% every round) AND you need to be to have a few big rounds where you greatly outperform almost everyone. Getting those big rounds means taking some calculated risks.


yeah matches my experience


RE: backtesting against bookies... are you backtesting against the opening odds or the final odds? Betting markets are like the stock market... the odds move as action is taken on the bet. So the initial price is like an IPO price, and then the market is what determines the final odds.


Depends on the dataset available. Usually final odds because that is what is preserved for posterity.

You are right of course. My back testing was more for interest than for any other purpose. And the bookies models are obviously optimising for other outcomes than mine.


For sure, there is still incentive for bookies to start with a price that is close to the ending price. And if you base your picks on a 'late' line then that is probably more likely to be a 'correct' line.


Well beyond even that, they're optimising for profit so they are looking for things like setting odds that match popular sentiment when the real outcome probability is significantly different.


Nice, I did a similar thing in 2018 with linear programming: https://peterellisjones.com/posts/fantasy-machine-learning/

I didn't win my friends' league, but definitely got closer than previous years


I really want to use these advanced approaches more, and they make a lot of sense in the daily fantasy scene (this analysis was for tourney long EURO 2024 I think?), but for something like season long NFL, I am convinced it is mostly luck:

  Hope your top 3 picks stay healthy

  Hope your 3-4 "flyer" picks (the guys who are on a new team, rookies, etc.,) don't completely bust

  Play the waiver wire (mid week pickups to fill in positions where needed) well
The one part where more skill/operations research is involved would be playing the matchups (top defense vs crap offense, WR1 vs rookie corner) but even then it's not a surefire recipe for success since there is so much variance (that top WR play might be nuked by a run oriented game). But it is playing smart so you should do it.


Almost every year my American football fantasy team is loaded with injuries. If your season is too long and close to the playoffs, teams will start benching star players so they don’t get hurt.

One of the worst parts for NFL are the divas who can’t control their off field behavior or emotions. I’m looking at you Antonio Brown.


Id love to see an analysis on skill v luck for nfl fantasy. Far too often do I see someone who does not watch football and does not make team changes win a league after drafting Tom Brady in the second round.


I used to be co-owner of an NFL fantasy prize league company (before Fanduel et al came along and put us and all of our competitors out of business). After a decade of seeing thousands of users create an manage teams for an entire season I'd say it's probably more skill than luck but luck plays a much bigger factor than people are willing to admit.

The biggest problem with leagues is everyone in the league remaining involved even when it's obvious they're out of the playoff race. This can lead to lopsided victories later in the season and change playoff seeding. This can be just as impactful as any injuries or bad weeks and the like. It was a constant challenge for us and is something the daily leagues don't have to worry about.

The fantasy playoffs are probably the most pure form of NFL fantasy leagues but that is also very dependent on who the opponents are for each of your players those last couple weeks and who is even avail to play given players being rested or injured later in the year.

In some ways this actually isn't a whole lot different than the actual NFL. That said we did seem to see the same people every year win more often than others, so it's not all luck.


To be fair, I've also seen actual NFL teams win way too many Super Bowls after drafting Tom Brady in the sixth round.


It doesn't work as well in fantasy because you can't deflate the balls or spy on the opponents' communications.


Heard on WGN Radio last week:

"My buddy and I were playing fantasy football, and he said, 'Letʼs make it interesting.' So we stopped playing fantasy football."


My favorite field, Operations Research. Nothing is as sweet. Nothing as elegant. Nothing as mindbreakingly infurating when you don't know the answer yet.


"I’m from Spain, so I’m speaking about the real and original football, the one that’s played with the foot and a ball, not with the hands and an egg"

Ha


> It didn’t consider the schedule of matches

This dynamic makes fantasy sports a second-order game, and predicting regular sports outcomes is hard enough. You're not just trying to pick the best players for the best price, you also have to consider the scenarios those players will be in any given week.


Which data did you use? Since the leagues were from the Quarterfinals and onwards, was it data from the group stages, euro qualifiers? Averaging the last 5 games would introduce a lot of variance, especially in tournament football.


I was using data from the group stages. And I agree that just using the last 5 games had a lot of variance, but unfortunately, I didn't have data from before the Euro.


This approach would be interesting to use in league football (La Liga, Premier League, etc) as there is a lot more data available across different seasons.


> The obvious solution for a data scientist like me was to use machine learning. But I didn’t. I just took the average score by the player during the last 5 games.

Wait, is he cracking a joke? If so, haha.


Surprisingly effective strategy. I've won a fantasy hockey pool by picking the next top available player.


Given that the mean is literally the expected value, I'm not all that surprised!


But the expected value of past games may not be the same as the expected value of future games.


It begs the question as to why one would prefer a more complex strategy.


First of all, other players are likely using the same naive approach and you need to differentiate yourself. Second, using simple EVs will give you consistent, but not top, results. You will likely always finish in the top third, but never in the top 1%, losing out to people who successfully predicted a low EV player's incredibly high output in a game.


Certainly the desire for a more sophisticated and robust model, but I'd be interested to understand the LOE involved and what levels of improvements are offered by said efforts. Perhaps the author can offer links to approachable books/articles on the matter?


The open league results are in part explained by the drop out rate of players who start then lose interest after a few weeks. Comparing against active players might be more reasonable (assuming this league wasn't choose once and do nothing for the season).


The most important thing is to make sure you use an encrypted email auth protocol.

I was in a tipping comp years ago. At this workplace I had already warned the management against insecure email protocols but they wouldnt listen.

Anyway, came time for the company footy tipping comp.

Once I worked out which manager was running it, I used their plaintext password against their admin login to the tipping website. Worked straight up.

Every week I would make my tips, then after the games had been run but before Monday rolled around, I would use the admin access to change my tips.

Didnt try and hide it just went 100% victory every week.

The admin of the comp would even go out of his way to try and satisfy the very angry football fans that it wasnt run on company systems so theres no way that I could find my way in to change things.

In the end I fessed up, I couldnt get them to change the email system, but he apparently proactively took the password post it note off of his monitor which was nice.


I didn’t 100% follow this story. Sounds like you knew the manager’s password and used it to log into a website. Where did the email protocols come into it?


Pulled it out of a packet capture


This was something of a surreal read. I assume "comp" is short for "competition". But what is "tipping"? What's a "tip"?


Betting.


Just out of curiosity, which country(s?) refer to that as tipping?


In German, "tippen" is a possible translation of "to guess". There's a well-known tradition of friendly betting on football matches with colleagues or friends (sometimes with money on the line, often not). These are called "Tippspiel" or "betting games".


https://idiomorigins.org/origin/tip

In English too - think "betting tip".


> In English too - think "betting tip".

A betting tip is when someone gives you information relevant to a bet.

That is a sense that definitely exists in English, but obviously there is no such thing as a "tipping competition" in this sense.


> If you happen to know how a player will perform in the game next week, please call me and we’ll get very rich and not just win a stupid fantasy game.

Another classic of the genre "why would I need you?"


I will play:

- they do not know how useful the skill is. (Cocks solved the public-key cryptography problem without knowing what it would be used for)

- they do not have the cash to invest => just a straight up lack of capital to make the ROI worth it.

- they are unable to bet in the geography they reside in => you need a middle man who can bet on your behalf.

But let's comment on a throwaway line in an otherwise interesting article. I wonder if this counts as bike-shedding.

Or maybe a classic of the genre "why was this comment needed?"


This comment thread is strange. I think you both raise interesting points, but are also rather hostile. Why not just respond sincerely? You have interesting things to say.


I felt OP was needlessly negative. In classic internet fashion, I added to that negativity. Not proud of it.


Why do you think they are insincere? They could sincerely be hostile and raise interesting points.


Eh, it’s just some sass.


In general, betting operators will throttle you down to 0$.

So there's actually a lot of work/skill involved in bypassing the limits so that you can continue to place bets.

Just knowing the existence of an arbitrage doesn't mean you have the opportunity to take advantage of it.


“Operations research” is a very fancy way of solving the knapsack problem (a simple algorithm you can implement in 10 min)





Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: