An advanced machine learning model utilizes a Random Forest Regressor to generate betting recommendations for Major League Baseball (MLB) games.
MLB Betting Recommendation Emailer
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.
Features
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.
Example Email
Technologies Used
- Python
- Pandas
- Scikit-learn
- pybaseball
- Gmail API
- The Odds API
- HTML & CSS
How to Use
- API Setup: Create a free account with The Odds API to obtain an API key. Store this key in a
.envfile asAPIKEY=<apiKey>.
- Gmail API Setup: Obtain credentials for the Gmail API and store them in a
credentials.jsonfile in the data directory. Then runmodules/quickstart.pyto generate atoken.jsonfile.
- Environment Variables: In your
.envfile, specify the email that is authorized with the Gmail API asBETEMAILand the recipient's email asRECIPIENTEMAIL.
- Execution: Run the
app.pyscript. This will fetch the betting lines, train the model, generate recommendations, and send an email with the betting recommendations to the specified recipient.