Using AI for Fantasy Baseball & Football Drafting
Here's how Claude has built my $1M side hustle that works for me while I sleep:
Just kidding! For those of you who made it through my AI slop intro, I'm planning to start writing monthly blog posts outlining my experiments with AI - about real use cases and learnings as I play around with AI.
It's undeniable how much software coding has changed with LLMs even in the past 3 months, so I've taken it upon myself to build more through fun side projects. I love sports, and so I hope to make many of my AI learning projects centered around sports applications!
🏈 Fantasy Football 🏈
The best way to ring in the end of summer? Football and AI! 🍁 🏈 🤖
Continuing my AI in sports theme, I built a fantasy football drafting tool (customizable for any league's settings and positional draft preferences)! Five expert sources are synthesized using Plackett-Luce, a model that turns ranked lists into a consensus (even when sources disagree/leave players out entirely). A Bayesian prior then keeps said consensus from swinging to extremes for a given player, while a bootstrap over the sources produces a projected range of a player's positional ranking. This allows someone to understand both where the draft sources agree, as well as how confident the consensus actually is - I paired this information with an LLM chatbot interface for further comparing players across positions/projected draft slots/team needs/etc. in more natural language format.
For the overall draft board itself, projected points are fitted per position with dynamic Value Over Replacement calculations (to show the value in taking a certain position now vs. waiting to draft it later). I also built in a Monte Carlo simulation to project the rest of a given draft at any point in time, based on 12 seasons of projection data and which players are likely to be available/valuable at the given simulated draft spots.
And post-draft, a full synopsis can also be saved off. This grades picks across positions to benchmark a roster (both against the AI's counterfactual "optimal" lineup and every other roster in the league).
As you can probably tell, I layered Bayesian statistics into this build (after reading "Everything is Predictable" by Tom Chivers). Bayesian statistics is a relatively new and interesting topic to me, and it shows here in terms of treating expert disagreement across rankings, quantifying a player's projected positional ranking as a range, and allowing users to update their draft ranking methodology with their own prior beliefs of RB vs WR expected positional value over the season i.e.
A few other fun features I built into this tool:
- (Work in progress) Live ESPN sync that updates your board as picks happen!
- Counterfactual optimal draft showing the best reachable roster with all opponent picks held fixed
- Player deep dives with 80% outcome intervals, source disagreement visualization, and QB-WR stack detection
- Color theming for all 32 NFL teams (I do work at a marketing company!)
Feel free to use this for your own league: a set-up PDF is linked here!
⚾ Fantasy Baseball ⚾
I have really enjoyed going to baseball games since moving to Boston, and this year I finally joined a fantasy baseball league. But I know very little about fantasy baseball strategy/most players who don't play for the Red Sox - so I Claude vibe-coded a Fantasy Baseball assistant app!
As you could probably guess from my prior March Madness-related articles, I love fantasy sports. I have played fantasy football for over half of my life, and I always struggle to say no to joining a new league - I was only in 4 this season which was actually very low for me!
I have the most fun drafting and picking up waiver wire players, and I like to imagine that my combined NFL knowledge via analytics + watching games on Sundays puts me at a competitive advantage to win (I enjoy making trades for the same reason, but I have the reputation amongst my friends of making one-sided trades since I often value my own players way too highly).
This year, I have decided to branch out and try new fantasy sports like basketball and baseball. I watch NBA games often in my free time, but baseball felt like a stretch because I only really watch the Boston Red Sox. And this felt like a perfect opportunity to test AI!
(Un)surprisingly, Claude Code built me a very viable AI Fantasy Baseball Assistant app/website within an hour - covering my fantasy draft board, a trade calculator, lineup recommendations, and more. Here's what I built and learned.
Objective
Project Goal
- Claude Code an app to guide fantasy baseball draft/waiver wire pickups/lineup selections/trade evaluations throughout the season
- Create an easy UI where I can save lineups & subsequent changes over time
Requirements
- Scrape data from the "best" fantasy baseball rankings website historically, in terms of its accuracy in predicted preseason vs end-of-season rankings (this ended up being fantasypros.com)
- Allow me to input which pick in the draft I have, and then select which players are drafted by others vs me over time so that I can easily see the "best" pick for me to select
- Make the draft board easily searchable so I can compare players against ESPN's draft board when deciding on value vs positional selections to make
- Based on prior draft picks made, highlight the players filling a specific need or value for my team (even if they are not the top player on the draft board)
- Leverage the realtime "MLB Stats" API to recommend the best weekly lineups maximizing total projected weekly points (automatically updating recommendations for injuries)
- Evaluate trade proposals to determine if I am giving up too much
Nice-to-haves
- Automatically update draft selections in realtime, with no manual intervention from me
- Recommend potential trades based on my own positional needs & the rising/falling value of my players over the course of the season
- Prioritize recommended waiver-wire targets based on predicted + in-season production
Learnings
What Went Well
I was extremely impressed with how well Claude Code did after just one set of prompts. The draft board output tool was clean and easy to search, and the various tabs + ability to undo picks was very organized and easy to understand.
[[IMAGE: draft board with team needs highlighted]] [[IMAGE: recommended lineups view]]This MVP app satisfied my proof-of-concept goals for a fantasy baseball assistant - a draft board customized to my team's biggest needs as the draft happens, recommended lineups, and a trade calculator!
Claude also asked me important clarifying context questions that I would not have thought to include in my prompt - such as the number of teams, the scoring format, and player position limits of the league. This feels like pretty simple info, but the fact that it asked me before creating an initial app shows that Claude quickly honed in on the context of fantasy baseball and asked important clarifies which ultimately helped it build a strong solution for my use case from the get-go. Further, it was very easy to determine from the initial Claude output which player(s) would have been selected/were still available at any given time by toggling between the available vs taken player tabs. Claude Code also seamlessly iterated on my feedback without changing any core functionality of the app that I did not ask to tweak, while also saving off new versions separately so that I could revert back to earlier app versions if an idea I wanted to test did not pan out.
[[IMAGE: draft board with clarifying-question setup]]I was impressed by Claude's ability to produce a working app concept based on a few clarifying questions. This allowed me to focus much more on the usability and new functionality of the app knowing that the initial tool was already in a great place.
Furthermore, I loved the green badges highlighting projected need vs value picks relative to my actual roster, as well as the one-sentence descriptions of each player's upsides (these summaries made it very easy to compare and select players whom I otherwise might not have known very much about). The projected needs vs high value picks would get updated in realtime as I inputted who had already been picked, which was super helpful. Aside from one scenario where I picked 3 shortstops when only having the space to start 2 at a time (welcome to the trade block, Trae Turner), the tool was very usable in terms of recommending high value picks for my team, even as draft selections are made very quickly in an 8 team league.
[[IMAGE: "URGENT NEED" pitcher badge example]]The app clearly labeled the player badges denoting need vs value throughout the draft process, and the below image represents an example of pitcher being an "URGENT NEED" as I got later into my draft.
[[IMAGE: trade value calculator interface]]The trade value calculator was an equally big win as well. I often struggle to determine players' trade values in any fantasy sport I play (and fantasy football is one of the few sports that even has a built-in trade calculator on some apps like ESPN Fantasy). As a data scientist, I also love having some evidence backing my decision-making.
The methodology here was relatively simple - utilize the same fantasypros.com rankings to assign points to each player (as the number 1 pick of 219 possible selections, Shohei Ohtani got 219 baseline points i.e.), and add 25 extra points to a player of positional need. It is hard to find a trusted fantasy sports trade evaluator - and without knowing your specific team, it becomes difficult to know if the player valuations are valid for your specific roster. The real value-add here is that my full roster could be saved off, such that the tool can easily cross-reference my team and recommend truly valuable trade insights alongside the projected trade valuations of any given player. In the future, I would love to upgrade this to proactively recommend trades to obtain "undervalued" players, to trade away any of my own players whose value seem to be peaking, and value target players based on injuries and actual fantasy performance throughout the season.
[[IMAGE: "Lean Accept" trade evaluation example]]In this hypothetical scenario, this is ruled a "Lean Accept" since my team seemingly is lacking strong Relief Pitchers.
Finally, I loved that Claude cited its sources on the end tool, in terms of player rankings, lineup projections, and trade valuations. This will make it very easy to cross reference and validate lineups and roster moves made.
[[IMAGE: sources-cited view]]What Did Not Go Well
Since AI is not perfect, I naturally ran into some hiccups along the way. For one, I had trouble getting the board to properly show every MLB player that should have been available to draft. When doing pre-draft research, I noticed that >30% of players I searched for when comparing my board vs ESPN's were not in my app's database yet. I love that Claude did extensive research on determining the "best" draft rankings site to leverage, but I wonder if it did not properly scrape the entire website's player database when initially compiling the app.
Or a classic AI hallucination was at play; for example, Diamondbacks star Ketel Marte did not show up on the draft board across multiple subsequent version iterations (who is ranked 27th on fantasypros.com, so by no means someone who wouldn't be included in any website's draft rankings). I thought that prompting examples of players that were missing would prompt Claude to find all missing players via some pattern recognition, but it was not until I explicitly asked it to cross-reference the entire mlb.com roster database that Ketel Marte's name (and all other missing players' names) were finally included.
Furthermore, without this tool being able to automatically update in realtime, it became difficult to make my picks while updating the tool for every selection made in the draft. This often left me scrambling to both update the tool while look at ESPN's board when it was my turn to draft, which I think actually led me to making some less well-informed selections (analysis paralysis/information overload). Our ESPN league is read-only, so in a future iteration here I wonder if I could actually have the tool auto-update its draft board so I could focus on my own research in between picks. I could see this type of implementation being difficult, but it would feel necessary in order to truly be a helpful tool during the draft.
Finally, I am unsure whether the tool will truly save off my lineup over time (or if I will have to re-input this every time I reopen the link). Since Claude outputted a simple HTML file that I then converted into a website, I think I'd only truly be able to save results if I did not close out this site's tab at all throughout the season. In reality, the end user tool does not need to be a website/app (it can be a local file that saves edits, as long as I could also share the starter file with friends in some user-friendly way too which was the intent for building an HTML file). The lack of saving also may make the trade value calculator less useful for friends - they would also have to input their roster in to truly see if the trade benefits them or me more per the methodology logic. I also don't think the MLB Stats API currently is being utilized correctly by the app as it's saying that healthy players are injured? As aforementioned, if the tool could read in all team's rosters from my ESPN league then there would be way more to unlock!
[[IMAGE: "Do Not Start" flagged players example]]I think the combo of the realtime API not being called properly + the lack of the site's ability to easily save & refresh in website format will need some improvements - I think that's why these players are posed as "Do Not Start" even though active?
What's Next
This was a really fun quick project to spin up, and I would love to compare/contrast this tool to how I would create something similar for fantasy football/basketball. I am excited to continue improving and updating the tool over the season as I actually use it, as I bet there will be a bunch of use cases that are must-haves that this tool doesn't yet cover in order to be an all-in-one fantasy baseball assistant. And if this tool works during the season, maybe I could even branch out to other leagues like fantasy hockey!
In terms of future functionality in the tooling itself, I would love to have this update more easily in realtime while fully saving off results in the process. And if this tool could be more user-editable (in terms of a new user being able to add in their league's setup and then it help them draft/set lineups/trade/etc) then this functionality could really scale. And using the resulting data it had for a given league, the more proactive recommendations/notifications that the tool could make about high-value trades/waiver wire pickups would really give users a competitive edge over others.
Please play around with my tool and comment any ideas/questions/feedback. Again, this was a pretty quick PoC but I would love to scale it via AI into something useful, even if just for my own love of fantasy sports!
Comments
Post a Comment