Inspiration

We have a deep love for basketball and we wanted to know if we could predict which NBA team would win in a game. So we made an ML algorithm in python that does just that.

CHECK OUT THE GITHUB REPO

What it does

A user will select 2 teams they want to pit against each other and our algorithm does the rest, deciding who will win!

How we built it

We used scikit learn, jupyter notebooks and selenium to process 29 years worth of NBA data

Scraping the web

We scraped advanced stats and per 100 possessions stats for the winners and losers of every nba playoff series between 1990-2019. We eneded up with 450 data points and 106 features.

Selenium

The project used Python Selenium to gather reference data from basketball-reference.com. Using XPath to identify HTML elements in tables based off their relative position to the names of the playoffs team, automation was used to gather the League stats for years 1990-2019. The script then pulled the text content from each HTML element, which would be the raw data the ML model would need, and wrote it into an easy to read CSV.

SciKit Learn

We implemented a logistic regression model. The model scored 77% accurate on test data (33% of the 450 samples)

Processing data

Sports evolve over time so it’s important to have variance in when the data comes from. We shuffled, balanced and combined data to prevent overfitting.

Removed redundancy

It’s important to remove variables that are unimportant or redundant. Based off our deep love for basketball we assessed and removed 84 variables that didnt impact our results.

Simplify and Select

We simplifed the model using sklearn’s SelectKBest function with various entries for k. So we then used pickle to use the model for flask deployment.

Accomplishments that we're proud of

We finished the ML model and put out an MVP

What we learned

Scikit Learn, Selenium, React, Flask

What's next for NBA Predictions

We hope to integrate the ML backend with our react frontend to provide a high fidelity user experience that predicts who will win

Built With

Share this project:

Updates