/NBA-games-visualization-and-shooting-success-probability

This Sports Analytics project aims at creating a visualization tool for basketball games, incorporating the shooting success probability at any time.

Primary LanguageJupyter Notebook

NBA-games-visualisation-and-shooting-success-probability

This Sports Analytics project aims at creating a visualization tool for basketball games, incorporating the shooting success probability at any time. This tool is a first step towards an in-game-decision analysis tool as it can be used to assess the relevance of the choice between making a pass and taking a shot. More detailed datasets could allow for the construction of a more developed tool analysing the Expected Point Value of each possible action (pass, shoot, layup, drive, etc.).

Project decomposition

This project has three main components:

  • A Logistic Regression model - built in the shot_success_probability.ipynb file - which outputs, given the distances between the ball carrier, the defender that is closest to him and the basket, a shooting success probability. This model has been created using the shot_logs.csvfile and can be found in the /model folder.
  • The data_transformation.ipynb noteboook that takes the .json games files that contain the positions of the ball and of the ten players on the court, completes and transforms it to prepare it for the animtation.
  • The animation.py file that displays the games' plays with the associated shooting success proability.

Data

The shot_logs.csv file used to build the shooting success probability model can be found on kaggle. It contains data on shots taken during the 2014-2015 season, who took the shot, where it was on the court, where was the closest defender, and more.
The game data can be found on this repository. It contains raw SportsVU game data from the 2016 season.

Results

Animation example

example gif

Shooting success probabilities on the court

  • Shooting success probability on the court with a closest defender 1 foot away from the ball carrier shooting success probability on the court with a closest defender 1 foot away

  • Shooting success probability on the court with a closest defender 2.5 feet away from the ball carrier shooting success probability on the court with a closest defender 2.5 feet away

  • Shooting success probability on the court with a closest defender 5 feet away from the ball carrier shooting success probability on the court with a closest defender 5 feet away

Organization of this directory

├── raw_data
│   ├── 0021500489.json
│   ├── 0021500492.json
│   ├── shot_logs.csv
│   └── court.png
├── python_code
│   ├── shot_success_probability.ipynb
│   ├── data_transformation.ipynb
│   └── animation.py
├── modified_data
│   └── gamedataset.csv
├── model
│   └── logit.pkl
├── results
│   ├── shooting_success_probability_with_dist_def_1.png
│   ├── shooting_success_probability_with_dist_def_2.5.png
│   ├── shooting_success_probability_with_dist_def_5.png
│   └── example.gif
└── README.md

1 directory, 8 files