Data science project examining which NBA players reliably punish defenses for leaving them open from three-point range.
"Which players on the other team do we never want to leave open at the three point line?"
Conversely;
"Which opposing players are we ok with leaving open at the three point line?"
Open Three-Pointer - a shot where the closest defender is:
- 4–6 feet away = open.
- 6 or more feet away = wide open.
The project was developed with Python 3.11.
Install the required packages from the project root:
python -m pip install -r requirements.txtThe project dependencies are:
- pandas
- NumPy
- Matplotlib
- seaborn
- SciPy
- scikit-learn
- nba_api
Run all commands from the repository root.
Sample versions of data are tracked in git but not used in the code. Needed directories may not be created, if not use:
mkdir data/raw/player_shooting
mkdir data/raw/player_stats
mkdir data/clean
mkdir output/figures
mkdir output/tablesInstall requirements if you have not done so already:
python -m pip install -r requirements.txtpython .\src\collect_data.pyThis downloads all needed data from the NBA API. The NBA API requires an internet connection and may respond slowly.
python .\src\clean_data.pyThis produces cleaned datasets in data/clean/.
python .\src\analyze_data.pyThis produces the statistical results, rankings, most reliable shooters table, and analysis figures.
python .\src\train_model.pyThis trains the linear-regression model and evaluates it on the 2024–25 to 2025–26 data.
Important figures:
leaguewide_contest_shooting_stats.pngopen_vs_wide_open_difference.pngopen_3PA_histogram.pngplayer_open_shooting_efficiency_vs_value.pngyear_to_year_open_shooting_stability.pngmost_reliable_shooters.pnglinear_regression_model_examination.png
Only most_reliable_shooters.csv is committed in output/tables/.
The other tables and figures are generated by the code.
The project collects regular-season player data from the NBA API for 5 seasons from 2021-22 to 2025-2026.
Two NBA API endpoints are used:
LeagueDashPlayerPtShot: player shooting totals for four defender-distance ranges.LeagueDashPlayerStats: overall player totals, including games, minutes, and three-point shooting.
The four defender-distance ranges are:
- Wide open: 6+ feet.
- Open: 4–6 feet.
- Tight: 2–4 feet.
- Very tight: 0–2 feet.
Data collection produces 25 raw CSV files:
- 20 player shooting files: 5 seasons × 4 defender ranges.
- Five overall player-statistics files.
The complete raw and cleaned datasets are excluded from Git because of their size. The files in data/sample/ document the raw and cleaned formats expected by the code but are not used directly by the code.
The following sample files are included to document the expected data, please do not run the code before doing the actual data collection step.
data/raw/player_shooting/sample_raw_player_shooting_data_2021-22_contest_open.csv
data/raw/player_stats/sample_raw_player_stats_data_2021-22.csv
data/clean/sample_combined_cleaned_shooting_stats_data.csv
353-project/
├── data/
│ ├── raw/ # Downloaded data
│ │ ├── player_shooting/
│ │ └── player_stats/
├── output/
│ ├── figures/ # Generated figures
│ └── tables/ # Generated tables
├── src/
│ ├── collect_data.py # NBA API data collection
│ ├── clean_data.py # Cleaning and dataset construction
│ ├── analyze_data.py # Statistical and descriptive analysis
│ ├── train_model.py # Model training and evaluation
│ └── config.py # Shared constants
├── .gitignore
├── README.md
└── requirements.txt