This advanced machine learning model utilizes a Random Forest Regressor to generate betting recommendations for Major League Baseball (MLB) games. By leveraging aggregated data from reputed sportsbooks such as Fanduel, DraftKings, and Barstool via The Odds API, and combining it with the team's performance metrics from the 2023 season, the model provides insightful betting line recommendations.
Data Aggregation: Fetches game data from The Odds API, which includes the latest betting lines from renowned sportsbooks.
Machine Learning Model: Utilizes a Random Forest Regressor to make predictions based on team performance metrics pulled from pybaseball.
Email Notifications: Sends betting recommendations via email, using a well-formatted HTML template.
Comprehensive Analysis: Considers various key performance metrics such as Runs, Hits, Runs per Game, On-base Plus Slugging, and more.
Modular Structure: The codebase is organized into modules for data fetching, processing, model training, and email utilities, making it easy to understand and extend.
![Screenshot 2023-08-10 at 1 37 43 PM](https://private-user-images.githubusercontent.com/43586291/259831359-69296959-8a0d-48f1-bd56-8f04f6f77580.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM4MjE3NjcsIm5iZiI6MTcyMzgyMTQ2NywicGF0aCI6Ii80MzU4NjI5MS8yNTk4MzEzNTktNjkyOTY5NTktOGEwZC00OGYxLWJkNTYtOGYwNGY2Zjc3NTgwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE2VDE1MTc0N1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTliMWU1ZGZmOTUzNTg4Zjc3YjIzZTY5ZmI0ZTA1NzczNWFmM2RlOTMyMWVmMDcyYzI1NjUzYjM2NmM4YTVlNDYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.nCBBG0qFHC2_ncb20wqHCEHNdPEOnK5sRBFFZb9r2ow)
- Python
- Pandas
- Scikit-learn
- pybaseball
- Gmail API
- The Odds API
- HTML & CSS
-
API Setup: Create a free account with The Odds API to obtain an API key. Store this key in a
.env
file asAPI_KEY=<apiKey>
.- Please see the Odds API docs for more info here
-
Gmail API Setup: Obtain credentials for the Gmail API and store them in a
credentials.json
file in the data directory. Then runmodules/quickstart.py
to generate atoken.json
file.- Read more on setting up the Gmail API with Python here
-
Environment Variables: In your
.env
file, specify the email that is authorized with the Gmail API asBET_EMAIL
and the recipient's email asRECIPIENT_EMAIL
. -
Execution: Run the
app.py
script. This will fetch the betting lines, train the model, generate recommendations, and send an email with the betting recommendations to the specified recipient.
Everyone is welcome to contribute to this project! Feel free to add new features, fix bugs, or make improvements. Just fork the repository, make your changes, and submit a pull request. I appreciate your help! :)
This project is intended for educational purposes only. It should not be used as the sole basis for actual betting decisions. Betting involves risk, and you should only bet with money you can afford to lose. Always bet responsibly.