Inspiration

As beginners, we all thought it would be a good idea to make a project based on our interests. One interest that we shared, albeit to varying degrees, was basketball, and while discussing possible projects we eventually settled on the idea of a trading software.

What it does

Users can select a team, and based on the current season's stats, the program will analyze the weak points in the teams' stats and suggest a trade target (who to trade + 10 potential targets that can be traded for).

How we built it

We crated a framework of stats to focus on as a baseline for ranking teams and their weaknesses.

We used the nba_api in order to pull seasonal stats directly from the official NBA stats page, for both team stats and individual player stats. Then, we created formulae to analyze data and sort players by rank for different stat categories (perimeter offense, interior offense, perimeter defense, interior defense).

From there we created a system based on euclidean distance in order to find the 10 most similar players by statline and output the values in a dictionary for the frontend.

For the frontend we used Vue.js to create a simple UI and to connect the python code with the frontend we used Flask to simulate a backend. On the website you select the team you would like to see the trades for and when you hit submit a POST request will be sent to the Flask Server with data containing which team you selected.

From there the team's name will be passed into our python functions and a dictionary containing the top 10 players that would help this team will be returned and will be displayed on the website.

Challenges we ran into

We initially had a much more ambitious goal of creating a model rather than a mathematical algorithm, however this idea quickly fell apart due to our lack of knowledge. In addition, we initially used cosine similarity rather than euclidean distance, which measures direction rather than magnitude, so our player similarity metrics were all completely wrong before that issue was caught. Also, one of our csv files took 6 hours to compile, and by the end of compiling, it disappeared due to an untimely crash, forcing us to shift our algorithm's inputs and work with what we had.

Accomplishments that we're proud of

Our main goal for this project was to obtain trade targets, and we definitely reached that goal, albeit with some marginally skewed data.

What we learned

We learned how to use similarity metric tools and how to iterate through pandas data structures, as well as how to troubleshoot and adapt to files spontaneously combusting. We also learned how to host python code on a website through Vue.js and flask

What's next for Baskemtbol

We plan to continue developing this project over a longer period of time in order to fulfill our original goal, which was to train and use a model for these trade predictions as well as allow it to auto update with seasonal data.

Built With

Share this project:

Updates