Living by the philosophy, "Small bets for entertainment, big bets to become like Li Ka-Shing," sports wagering offers an adrenaline-filled experience. The hook lies in the unpredictable outcome, which keeps the excitement high throughout the match.
Over the decades, we have donated an enormous amount of money to the Hong Kong Jockey Club (HKJC) because of losing bets. Our betting was based on intuition and conviction rather than rigid strategies. With the 2022 FIFA World Cup on the horizon, discussions around strategic betting escalated, leading to the idea of developing machine learning models to predict match outcomes.
Image Credit: Ping Wo Fund
First Published: 26 November 2022
Last Updated: 23 August 2024
In our experience, we have found that Asian Handicap is extremely intriguing, yet the harshest option. It levels the playing field between the home and away teams, making it a real challenge to predict the winning side. That being said, dealers usually offer more favourable odds.
Our goal is to make predictions on Asian Handicap, specifically on the J1 League. Wager Optimiser covers an end-to-end machine learning (ML) lifecycle from data gathering to ML model management. By leveraging the power of ML, gamblers worldwide (end users) can easily get betting hints toward the results and optimise return on bets (RoB).
As of the time of writing, the optimiser has achieved an F1 score of 0.67 in handicap prediction for the 2024 season. Let's say you are betting with HKJC, the average odds are around 1.8. The optimiser recommended betting on 171 games, of which 116 were bingo. The minimum cost was HKD 34,200, and the expected return was HKD 41,760. This results in a RoB of 22.1%. Does it sound appealing?
Caution
Any betting decisions made based on these recommendations are at users' own risk.
If you are an addicted gambler, do you dare to bet on Asian Handicap with us? Are you brave enough to bet on a team without analysing any historical data, but putting your trust in the optimiser?
Simply visit Wager Optimiser on Streamlit Community Cloud and you can find the latest recommended bets.
Tip
Life is too short to regret not betting on Asian Handicap.
Match Summary
Handicap Prediction
Model Training
Model Evaluation
Model Register
You can host a full version of Wager Optimiser in your preferred environment. The instructions below will guide you through the deployment process. Due to copyright issues, team logos are not bundled within the repository and the Docker image. You might need to source those images by yourself if you wish to fully reproduce the app.
Caution
Any betting decisions made based on these recommendations are at users' own risk.
🐳 Docker Host
The optimiser consists of two parts: a backend server and a frontend server. Docker Compose will help create these containers all at once. Before following the steps, make sure your computer has Docker installed to host the optimiser.
- Clone the repository and navigate inside the folder.
$ git clone https://github.com/Jack-cky/Wager-Optimiser.git $ cd Wager-Optimiser/docker - Host the optimiser.
$ docker compose up -d
☁️ AWS ECS Host (Recommended)
Because H2O has certain hardware requirements, it is recommended to deploy it on a cloud service. Before following the steps, make sure your computer has Terraform installed to provision an ECS service on AWS.
- Clone the repository and navigate inside the folder.
$ git clone https://github.com/Jack-cky/Wager-Optimiser.git $ cd Wager-Optimiser/terraform - Update AWS access keys inside
main.tfaccess_key = "your_aws_access_key" secret_key = "your_aws_secret_key" - Initialise a working directory.
$ terraform init
- Create an execution plan for AWS environment.
$ terraform plan
- Provision an ECS to host the optimiser.
$ terraform apply -auto-approve
Once your deployment is ready, simply visit <ip_address>:8000 for the backend API service and <ip_address>:8501 for the frontend platform.
The architecture comprises two components: a frontend server and a backend server. Every week, Football-Data updates leagues match results and odds records in tabular data format.
The backend server downloads the data and processes it for statistics queries and match predictions. There are two ML models trained in the optimiser: (1) the Goal Probability Matrix (GPM) and (2) the Handicap Predictor (HCP). The GPM models are trained using the Poisson model API from statsmodels, while the HCP models are trained using H2O AutoML.
Since the optimiser handles two ML tasks with multiple models, we adopted MLflow to manage the ML experiments and keep track of their performance for each task. After cherry-picking the models, they are served as API endpoints with FastAPI.
The frontend server is a multi-serving platform built with Streamlit. It is used not only for match queries and predictions, but also for managing ML models on the same platform.
As experienced gamblers, we can state with certainty that no single game outcome is guaranteed. An outstanding team can suddenly underperform when facing a seemingly weaker team (outliers). Likewise, a team's performance can vary dramatically from season to season (data drift). Handling these shifts manually can become burdensome. That's why predicting the handicap necessitates the use of MLOps to alleviate the depressing task of hyperparameter tuning and retraining models on a seasonal basis.
Goal Probability Matrix forecasts the probabilities of correct scores.
The GPM model assumes the number of goals follows a Poisson distribution and formulates the difference as a Skellam distribution. (Credit goes this post for the modelling idea). Theoretically, it models the correct score accurately when teams behave according to a Poisson distribution. We hope this WRONG model could be USEFUL enough to provide gamblers with a high-level insight into their past score distribution.
Handicap Predictor predicts the results of Asian Handicap.
The HCP is a two step model with two steps: (1) predicting which side is winning and (2) deciding whether the game is a confident bet. The first layer learns from the net difference in team properties, such as seasonal rank and scores, while the second layer builds upon the predicted probabilities and the actual result. This design aims to prevent gamblers from betting on uncertain games.
Suppose you want to deploy the optimiser in an AWS environment. It will be deployed to an ECS to host both the frontend and the backend in a single service. As each team plays a game once a week, running the service for one hour per week is sufficient for prediction and ML model management. This will cost approximately USD 0.35 per month for operation, which can definitely be offset by the RoB. Detailed price calculations can be found on the calculator.
[2.0.1] 2024-08-23
- Leveraged MLflow to track model experiments.
- Hosted the models' API with FastAPI at the backend server.
- Built a frontend interface using Streamlit to productionise the workflow.
- Switched the data source from using TotalCorner to Football-Data.
- Used H2O AutoML to replace manual model tuning.
[1.0.1] 2022-11-26
This project is managed with a product backlog. You can review the backlog to understand the prioritised list of features, changes, enhancements, and bug fixes planned for future development.
This project is licensed under the MIT License. See the LICENSE file for details. Feel free to fork and contribute to its further development!