All Projects → christopherjenness → Nba Prediction

christopherjenness / Nba Prediction

Predict scores of NBA games using regularized matrix completion

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Nba Prediction

mysportsfeeds-r
R wrapper functions for the MySportsFeeds Sports Data API
Stars: ✭ 27 (-78.91%)
Mutual labels:  nba
Nba.js
A Node.js library for current and historical NBA stats, scores, and data.
Stars: ✭ 339 (+164.84%)
Mutual labels:  nba
Nba api
An API Client package to access the APIs for NBA.com
Stars: ✭ 881 (+588.28%)
Mutual labels:  nba
nba-stats-client
🏀 JavaScript Client for stats from NBA.com
Stars: ✭ 29 (-77.34%)
Mutual labels:  nba
mysportsfeeds-node
NodeJS wrapper for the MySportsFeeds Sports Data API
Stars: ✭ 62 (-51.56%)
Mutual labels:  nba
Nba Player Movements
🏀 Visualization of NBA games from raw SportVU data logs
Stars: ✭ 481 (+275.78%)
Mutual labels:  nba
mysportsfeeds-api
Feature requests for the MySportsFeeds Sports Data API.
Stars: ✭ 44 (-65.62%)
Mutual labels:  nba
Basketball analytics
Repository which contains various scripts and work with various basketball statistics
Stars: ✭ 88 (-31.25%)
Mutual labels:  nba
Basketball reference web scraper
NBA Stats API via Basketball Reference
Stars: ✭ 279 (+117.97%)
Mutual labels:  nba
Nbaplus
A concise APP about NBA News and Event with RxJava and EventBus
Stars: ✭ 701 (+447.66%)
Mutual labels:  nba
nba-analysis
Using machine learning libraries to analyze NBA data
Stars: ✭ 14 (-89.06%)
Mutual labels:  nba
NBA-analytics
Short, offhand analyses of the NBA
Stars: ✭ 37 (-71.09%)
Mutual labels:  nba
Sprintnba
🏀 NBA客户端
Stars: ✭ 629 (+391.41%)
Mutual labels:  nba
NBA-Machine-Learning-Sports-Betting
NBA sports betting using machine learning
Stars: ✭ 150 (+17.19%)
Mutual labels:  nba
Xbmc.plugin.video.nba
Kodi plugin to watch NBA games with nba league pass
Stars: ✭ 42 (-67.19%)
Mutual labels:  nba
nbasixdegrees
An implementation of six degrees of separation for mutual NBA teammates.
Stars: ✭ 15 (-88.28%)
Mutual labels:  nba
Nba Go
🏀 💻 The finest NBA CLI.
Stars: ✭ 3,634 (+2739.06%)
Mutual labels:  nba
Nbareact
🏀 iOS and Android NBA app created with React Native
Stars: ✭ 101 (-21.09%)
Mutual labels:  nba
All Nba
Android app for NBA fans. Features live scores, highlights and Reddit integration for discussions.
Stars: ✭ 65 (-49.22%)
Mutual labels:  nba
Nba
Node.js client for nba.com API endpoints
Stars: ✭ 637 (+397.66%)
Mutual labels:  nba

NBA-prediction

Coverage Status

Predicts scores of NBA games using matrix completion

The Model

For a given NBA game, if you could accurately predict each team's offensive rating (points per 100 possessions) and the pace of the game (possessions per game), you could estimate the final score of the game.

Predicting a team's offensive rating against another team is tricky. It depends on how good the offensive team is at scoring and how good the defending team is a defending. Most importantly though, it depends on the specific matchups between the two teams. This is reminiscent of recommendation systems where the recommendation depends on the type of user, the type of product, and the affinity between those two. Furthermore, for a given season only some offensive ratings between teams are available (the teams that have already played). The strategy in this model is to use matrix completion techniques to estimate unseen offensive ratings. These will be combined with pace estimations to predict final scores.

Matrix completion

Here, we look at two methods for matrix completion: Maximum Margin Matrix Factorization (MMMF) and Singular Value Decomposition (SVD).

Hastie, Trevor, Robert Tibshirani, and Martin Wainwright. Statistical learning with sparsity: the lasso and generalizations. CRC Press, 2015.

Maximum Margin Matrix Factorization (MMMF)

The objective of MMMF is approximate an m x n matrix Z by factoring into

1

where A is an m x r matrix and B is an n x r matrix. Effectively, this puts a rank constraint r on the approximation M.

This can be estimated by solving the following

2

where Omega indicates that only the known values in Z should be taken into consideration. Any unknown value is treated as zero.

While intuitive, this approach has a two of problems. First, this is a two dimensional family of models indexed by r (the rank of the factorization) and lambda (the magnitude of regularization), which requires a lot of tuning. Second, this optomization problem is non-convex and in practice did not find global minima when used to predict NBA offensive ratings. Because of this, we turned to SVD.

Singular Value Decomposition Using Nuclear Norm

SVD, not explained here, can be used to provide a rank-q approximation of a matrix (Z) by constraining the rank of the SVD (M). This amounts to the following optimization

3

If values are missing from Z then you can constrain M to correctly impute these values, while approximating the unknown values

4

Where omega is the set of known values. However, this problem is NP-hard and also leads to overfitting since the known values are required to be predicted exactly. Instead, you can simultanously predict unknown values and approximate known values by solving the following optimization

5

Like MMMF, this problem is non-convex. However, it can be relaxed to the following convex optimization problem

6

where a nuclear norm on M, ||M||* is used. This algorithm, called soft-impute, is studied extensively in:

Mazumder, Rahul, Trevor Hastie, and Robert Tibshirani. "Spectral regularization algorithms for learning large incomplete matrices." Journal of machine learning research 11.Aug (2010): 2287-2322.

Example Code

To make predictions, use the following code:

>> model = NBAModel(update=True)
>> model.get_scores('PHO', 'WAS')
PHO WAS
92.9092883132 97.1806398788

which predicts the Suns will lose to the Wizards 93-97.

Note, scraping all the data required to run the algorithm is slow. This only needs to be done the first time. On subsequent models, you can use update=False to used the cached data.

Model Tuning and Test Error

The optimization strategy above is parameterized by lambda, the extent of regularization. Using a validation set (10% of sample), we determined 25 to be optimal value of lambda.

Imgur

Using lambda = 25 on a held out test set, our model estimates a team's final score with an MSE of 6.7. Not bad.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].