A machine learning project that combines a basketball game simulation with polynomial regression to predict optimal shooting parameters.
This project consists of three main components:
- An interactive basketball game where players can manually shoot baskets
- A data collection and model training system using polynomial regression
- A testing environment to validate the trained model
Basketball_ML/
├── training_game.py # Interactive basketball game for data collection
├── poly_regression.ipynb # Jupyter notebook for model training
├── test_model.py # Game environment for testing the trained model
├── data.csv # Collected game data
└── model.pkl # Exported trained model
- Interactive basketball shooting game
- Manual control of shooting parameters (speed and angle)
- Automatic data collection after each shot
- Data stored in CSV format with the following parameters:
- Speed
- Angle
- Rim_center_x (basket position)
- Jupyter notebook environment for data analysis and model training
- Uses scikit-learn library for polynomial regression
- Processes collected game data from data.csv
- Exports the trained model as a pickle file
- Testing environment for the trained model
- Imports the trained polynomial regression model
- Allows validation of model predictions in the game environment
pip install numpy pandas pickle pygame scikit-learn
-
Data Collection
python training_game.py
- Play the game manually
- Data will be automatically saved to data.csv
-
Model Training
- Open
poly_regression.ipynb
in Jupyter Notebook - Run all cells to train the model
- The model will be saved as
model.pkl
- move the model to teams folder(create one if it doesn't exist)
- Open
-
Testing
python Test_model.py
- Test the trained model's predictions