This project applies a mathematical model to U.S. counties to estimate the level of fan support for professional sports teams. It is inspired by several Tableau maps that visualize based on Twitter followers by county:
-
https://public.tableau.com/app/profile/matt.sorenson/viz/NFLFollowerMap/NFLMap
-
https://public.tableau.com/app/profile/matt.sorenson/viz/MLBFollowerMap/MLBMap
-
https://public.tableau.com/app/profile/matt.sorenson/viz/NBAFollowerMap/NBAMap
-
https://public.tableau.com/app/profile/matt.sorenson/viz/NHLFollowerMap/NHLMap
-
https://public.tableau.com/app/profile/matt.sorenson/viz/MLSFanMap/MLSMap
These visualizations rely on Twitter followers, which often provide small sample sizes at the county level.
This model doesn't model whether people are fans of a given team. First value computed is a percentage of potential revenue going to a partiular team in a county. This is realistic that money even from someone who dislikes sports finds it way to team "coffers". This is could happen via cable TV packages and the person buying a merchandise as a gift for a fans. Even fans of a rival team might attend a local game the benefits both teams.
There is a secondary value based on its distance from the venue that provide an multiplier to indicate the value the population of that county has to the team. A fan in a distant county is less likely to attend game(s) in person, but could buy a merchandise and other things. That multiplier might be something like 20% for a county 200 miles from the venue. Median income is taken into account where wealthier areas are more likely spend money supporting teams.
This "population value" is not a specific dollar amount but should be interpreted relative to each other.
This started as a Jupyter notebook and turned into an exercise in scaling and distribution.
Juypter notebooks were at first an exercise to implement the idea and sharpen my Python skills. Being able to host notebooks using the Voila library was worked very well as long as someone downloads the Docker image and runs it locally and preferrably a Linux machine. In theory it should work on a Windows and Mac/OS but users have to be tech savvy in all of these situations.
I want feedback from sports fans and people who like to speculate on such things. Those people are not necessarily techically inclined so I decided to just host the Voila application somewhere.
I eventually hosted it on an inexpensive Amazon EC2 instance. Using Python for the computation meant that one user can bring the instance to its knees running four notebooks at the same time. It wasn't ready for public consumption.
There was optimizations done to the Python code that speed things up but after attending a Python meetup on PyO3, the obvious next step was Rust!
Writing the computations in Rust sped things up immenselessly, but I still dissatified that I was burning my free AWS credits on a idling EC2 instance. So the next step is a Rust-based computation as a REST endpoint for an AWS Lambda and with a React client.
This led to the project being subdivided into sub-projects:
The original project using PyO3 to interface with the Rust computation logic.
At first the Lambda, PyO3 and Tauri version was duplicated the core computation logic. This keeps the core model logic "DRY".
A basic Axum server to provide a REST API for the Rust computation logic and can serve the react_interactive frontend.
The Rust computation logic wrapped in a AWS Lambda accessible via REST.
React frontend for the Rust computation logic. Can be used with the Axum server, the AWS Lambda or a Tauri desktop application.
AWS Serverless Application Model for deploying Lambda zip, Gateway API configuration and React frontend.
Things taken into account:
-
Popularity of the league / sport (league_weight)
-
Long-term establishment of the team. This could called allegiance, equity, etc. Referred to as "L"
Represents durable support built over time by:
-
Existing continually in a market
-
Sustained fan engagement usually from competitive success.
-
Can stagnate or decline during long periods of apathy, irrelevance, or losing
-
-
Short-term enthusiasm. ("S")
Represents excitement, novelty, and momentum:
-
Expansion and relocated teams.
-
Strong recent performance (especially for teams that aren't not typically elite)
-
Arrival of marquee or young phenom players
-
-
National footprint. In the code, "N".
Measures cultural influence beyond local geography:
-
Large markets get a lot of attention. Also higher populations would lead to more people from larger market relocated to smaller ones. (e.g. More Chicago raised people in St. Louis area than the other way around.)
-
Dedicated broadcaster like WGN (Chicago Cubs), TBS (Atlanta Braves) and KMOX Radio historically for the St. Louis Cardinals.
-
Star-driven brands (e.g., Messi, LeBron, Ohtani)
Other Modifiers:
-
Teams other than the nearest team with have an effective distance that is longer.
-
Teams in other states will have a effective distance multiplier. Even bigger for teams in Canada.
-
The code does none of the "L", "S" or "N" accumulation over time. The current values are subjective. Mentally modelling them would include:
-
"L"
Team has existed in the same market for long time. Stagnates or even goes down with prolonged apathy indicated by "S". Example of losing "L" is the Pittsburgh Pirates.
-
"S":
Maybe reduced by period where other team in market have higher "S". Example would be St. Louis football Cardinals in 1980s when the long established baseball Cardinals played in three World Series'. Inability to build "L" when in theory a football team should be "top dog" (higher league_weight) in the market led to the teams relocation to Phoenix.
New venue that over time adds to "S" and which helps build "L"
"N":
Larger markets teams with big name rosters will have higher value here.
- Iconic teams retain reputation even outside peak eras (e.g., Dallas Cowboys)
-
Model what might happen if a league implemented some kind of pro/rel scheme. National footprint ("N") would be immediately lower. Enthusiasm for such team would go negative ("S") and that would lower long term allegiance ("L") if promotion is earned back quickly.
-
Residual loyalty to a relocated team like the Raiders in LA.
-
Residual hostility toward a team that departed a market, but this is likely balanced out by residual loyalists and if the new market is distant, there not much of an impact. The Dallas Stars are too far from the Twin Cities for this to factor much.
-
In baseball, having a minor league affiliate in a remote county should increase loyalty even over a closer market. The model might favor Cardinals and Royals over Cubs in Iowa. However, the Cubs have AAA in Des Moines and seem favored in the state.
-
Experimenting with having a "virtual" team in location with same name as parent club or former club to represent the impact of minor league affiliates and residual loyalty. Residual hostility would probably require negative values calculating a teams presence.
-
Modifier to the "N" or "L" on the based on the state of the county. Northern states should have an higher affinity for hockey. Maybe Texas for football. If this thing was really comprehensive it would at the county level incorporating demographic information, but that is way out of scope right now.
-
Presences of lower league teams or major college programs in basketball and football could impact pro fandom. This is more of a factor with modeling the "L", "S" values.
-
Oh, Canada and to a certain extent Mexico. Canadian Bills fans and Mexican Cowboys fan exist.
-
Simulate upstart leagues. Instead of leagues have a higher level "sport" category. Upstart leagues would have lower "L" values but could have a bit of "S". Sometimes upstart and lower tier league can get support similar to major sports like FC Cincinnati when it was in the USL-Championship or the St. Louis Battlehawks of the UFL. Might not be much impactful if the seasons are not head-to-head, but FC Cincinnati likely drew fans away from Columbus. Hypothetical mergers could be simulated. What if Houston and Cincinnati also joined the NHL with the WHA merger? What if the IHL survived and forced a merger in the NHL in the '90s?
Distances are direct "as the crow flies". This leads to quirks where teams in western Michigan are more loyal to Green Bay or Milwaukee than they likely are. Particular around bodies of water is one place this kind of stuff occurs. This has been taken care thought it needed more horsepower than Python can provide (Rust). To keep things fast the model is focused on the lower-48 of the US. Any parts of a line between a county and a venue that leaves the lower-48 whether going over water or Canada as effective distance increased.
A farther market may be easier to travel to. Springfield Missouri is closer to Kansas City than St. Louis, but has more Cardinals fans. Recently the Cardinals put a AA affiliate there but I-44 is a factor. This is a bit mitigated by the having the AA team in the data.
Since the NFL's Giants and Jets play in the same venue, it will be a challenge to program in the geographic tendencies on those two teams. This could be mitigated be having a "virtual" teams in various boroughs. The Jets used to play at Shea Stadium so a "virtual team" is there.

