← All projects

AFL Game Ranking System

AFL results, predicted.

A web app that predicts AFL matches. Pick two teams and it forecasts each side's score, the winner and how confident the model is, beside each team's strengths and their scores round by round. It was a final-year project by a team of five Monash data science students, and I was one of them.

Prediction

Predict the stats, then the score.

Before a game, nobody knows how many disposals or tackles each side will have, so the model predicts those first. 22 CatBoost models, one for each of 11 team statistics on each side, work from what is known in advance: the teams, the round, the venue, the year and the day's temperatures. Two more CatBoost models then take those predicted statistics and predict the home and away scores.

Confidence

A winner, and how sure it is.

The score models give a spread as well as a score. The app turns that spread into a confidence percentage, higher when the spread is narrow. The predicted winner is highlighted, and the confidence shows as a percentage and a bar.

Comparison

Two teams, side by side.

Choose a match and each team gets a radar chart of five ratings, attack, defence, speed, teamwork and hustle, with its points total beside it. Below, a Plotly chart follows both teams' scores round by round, and draws the prediction on as a dashed line to the next round.

Teams

Every club, every player.

Each team has its own page with its captain and coach, and a full list of its players with their position and games played, all served from MongoDB.

And the details.

How it's built

Next.js, React, Python.

A Next.js and React front end with Tailwind CSS, Framer Motion, Chart.js for the radar charts and Plotly for score history. Team, player and match data live in MongoDB. The models were trained in a Python notebook with pandas, scikit-learn and CatBoost, then saved for the app to load.

  1. Python behind a Next.js route

    The predict route starts the Python script with the match details as arguments, then reads the scores, winner and confidence back from it as JSON. The script loads the trained models and label encoders from the files the notebook saved.

  2. Two stages

    Player performance isn't known until the game is played, so the first stage predicts it from pre-match details. The score models get more to work with, while still using only what's known before the first bounce.

  3. From XGBoost to CatBoost

    The first model was a single XGBoost regressor predicting both scores from match details. The final one uses CatBoost, which takes categories like team and venue directly and can predict with uncertainty, the source of the confidence figure.

AFL Game Ranking System. AFL results, predicted.

NextVisualizing Renewable EnergyRenewable energy, in five charts.