November 5, 2024 (1y ago)

Predicting the NBA MVP

titlepic

In the image above we have the Vegas odds for NBA MVP as of November 5th, 2024. We're going to see if we can make a low-effort model that approximates this list, with minor exceptions.

Note: These are betting odds so they take into account peoples' irrational behaviours, like voting Anthony Edwards for MVP. Statistically, based on age and overall performance, he'd be an outlier MVP.

Similarly, Denver had a poorly rated offseason (so Jokic's team seems likely to underperform), and he has also won 3 of the last 4 MVPs (contributing to voter fatigue). This model takes sentiment into account, so barring the Nuggets finishing Top 4, I don't expect Ant or Jokic to top our charts right now.

titlepic

I use the NBA Stats API found here to pull all player stats.

Specifically, I pulled the top 50 players by efficiency and their season stats from the leagueleaders endpoint for the last 10 years. With that data I was able to create rank and per-game features as well.

I then used the playerawards endpoint to tag MVPs and teamyearbyyearstats for Team metrics like Win Percentage and Conference Rank.

Finally, 3rd party libraries pytrend and feedparser helped us search for Google trend scores and ESPN RSS mentions for each player each season - unfortunately the RSS feed only goes back 14 days so we scrapped that.

Thankfully there were no null features in this dataset and only a few special characters in players' names to account for. But it's important to test for feature importance, especially when pulling a lot of potentially redundant features (like Total Points and Points per Game).

Recursive Feature Elimination and Permutation Importance are two common and simple methods for checking the impact of features on a test. In this case we used RFE, along with a Correlation Matrix and Scree plot.

titlepictitlepic

Correlation Matrixes can be helpful in spotting highly correlated and thus redundant features, while Scree plots give you their own estimation of the most important features.

The data recommended we use ['REB', 'PTS', 'EFF', 'MIN_per_game', 'EFF_per_game', 'PTS_per_game_rank', 'EFF_per_game_rank', 'PTS_rank', 'EFF_rank', 'WIN_PCT'], which I trimmed down to ['MIN_per_game','EFF_per_game', 'PTS_per_game_rank','PTS_rank', 'EFF_rank','WIN_PCT'] for the final dataset.

titlepic

The models appear overfitted, but they aren't predicting past winners and it is producing unique new players that we would expect to see, in Jayson Tatum and Anthony Davis.

To reach these predictions, we used three different models:

  • Random Forest: These models essentially create multiple large decision trees and find the most likely path. Usually better for a more complex and resource-intensive dataset but still useful here.
  • Gradient Boosting: Slower than Random Forest if training large models, but typically provides better prediction accuracy.
  • XGBoost: Incorporates L1 and L2 regularization to reduce overfitting, but can be sensitive to outliers.
  • Since all of these predict Tatum (pre-season favorite on the consensus best team) or Anthony Davis (off to a very hot start), I feel good about our chosen features. For more complex forecasting we'd likely have more to do on cleaning and prepping the data, and would evaluate our chosen models more closely - but for a quick and dirty project, we've now got ourselves a simple model for predicting the NBA MVP that we can have some confidence in.