Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NBA Reliable Open Three-Point Shooters

Rohin Aulakh - CMPT 353

Data science project examining which NBA players reliably punish defenses for leaving them open from three-point range.

Project Question

"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.

Requirements

The project was developed with Python 3.11.

Install the required packages from the project root:

python -m pip install -r requirements.txt

The project dependencies are:

  • pandas
  • NumPy
  • Matplotlib
  • seaborn
  • SciPy
  • scikit-learn
  • nba_api

Running the Project

Run all commands from the repository root.

1. Create the local directories

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/tables

2. Install Requirements

Install requirements if you have not done so already:

python -m pip install -r requirements.txt

3. Collect raw data

python .\src\collect_data.py

This downloads all needed data from the NBA API. The NBA API requires an internet connection and may respond slowly.

4. Clean and combine the data

python .\src\clean_data.py

This produces cleaned datasets in data/clean/.

5. Run the analysis

python .\src\analyze_data.py

This produces the statistical results, rankings, most reliable shooters table, and analysis figures.

6. Train and evaluate the model

python .\src\train_model.py

This trains the linear-regression model and evaluates it on the 2024–25 to 2025–26 data.

Generated Outputs

Important figures:

  • leaguewide_contest_shooting_stats.png
  • open_vs_wide_open_difference.png
  • open_3PA_histogram.png
  • player_open_shooting_efficiency_vs_value.png
  • year_to_year_open_shooting_stability.png
  • most_reliable_shooters.png
  • linear_regression_model_examination.png

Only most_reliable_shooters.csv is committed in output/tables/. The other tables and figures are generated by the code.

Data

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.

Sample Data

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

Repository Structure

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

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages