Skip to content

About

End-to-End Machine Learning application built with Django and Scikit-Learn. Predicts Premier League match outcomes using Rolling Averages, xG analysis, and Team Tier classification.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

Repository files navigation

⚽ Premier League AI Predictor

An end-to-end Machine Learning web application that predicts English Premier League match outcomes with high precision using advanced statistical metrics.

Project Status Python Django ML

📌 Overview

This project is a full-stack data science application designed to predict football match results. It automates the entire lifecycle of sports analytics:

  1. Data Collection: Scrapes detailed match statistics (Possession, xG, Shots) from FotMob using a custom Selenium bot.
  2. Data Processing: Calculates rolling form, offensive/defensive strength, and "Expected Goals" (xG) trends.
  3. Prediction: Uses a trained Machine Learning model to calculate probabilities for Home Win, Draw, and Away Win.
  4. Visualization: Presents insights via a modern, responsive Web Interface.

🚀 Key Features

  • Automated Data Pipeline: A robust Selenium scraper that handles dynamic content, cookie consents, and anti-scraping measures to build a comprehensive historical database.
  • Advanced Feature Engineering:
    • Rolling Form: Analyzes the last 5 matches for each team to gauge current momentum.
    • Tier System: Dynamically assigns team strength tiers to model "Giant vs. Underdog" scenarios.
    • xG Integration: Uses Expected Goals as a primary predictive factor, superior to raw goal counts.
  • RESTful API: Exposes prediction endpoints via Django REST Framework.
  • Modern UI: A clean, responsive frontend built with Vanilla JS and CSS3 (Glassmorphism design), featuring dynamic team logo loading and confidence bar charts.

🛠️ Tech Stack

Backend & API

  • Python 3.10+
  • Django & Django REST Framework: For robust API architecture and ORM.
  • PostgreSQL / SQLite: Data persistence.

Machine Learning & Data

  • Scikit-Learn: For predictive modeling (Random Forest).
  • Pandas & NumPy: For efficient vectorised data manipulation.
  • Joblib: Model serialization.

Data Acquisition

  • Selenium Webdriver: For scraping dynamic JavaScript-heavy websites (FotMob).
  • Chrome/Gecko Driver: Headless browser automation.

Frontend

  • HTML5 / CSS3: Custom responsive design.
  • JavaScript (ES6+): Async API calls and dynamic DOM manipulation.

🏗️ Architecture

graph LR
    A[FotMob Website] -->|Selenium Scraper| B(Raw Data)
    B -->|Preprocessing| C{PostgreSQL Database}
    C -->|Rolling Stats| D[ML Model inference]
    User -->|Select Teams| E[Web Interface]
    E -->|REST API Request| F[Django Backend]
    F -->|Query| D
    D -->|Probabilities| F
    F -->|JSON Response| E
Loading

🔧 Installation & Setup

Prerequisites

  • Python 3.8+
  • Google Chrome (for the scraper)

1. Clone the Repository

git clone https://github.com/SirbuRobert/epl-ml-forecaster.git
cd epl-ml-forecaster

2. Create Virtual Environment

python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

3. Install Dependencies

pip install -r requirements.txt

4. Database Setup

python manage.py migrate

5. Run the Application

python manage.py runserver

Visit http://127.0.0.1:8000 to see the predictor in action.


📊 How to Run the Scraper

To update the database with the latest match results:

python scraper/run_ingestion.py
  • Note: The scraper runs in headless mode by default. It handles cookie popups and navigates match rounds automatically.

🧠 Model details

The prediction engine uses a Random Forest Classifier approach. Key features used for training:

  • Relative Form: Difference in points over the last 5 games.
  • xG Differential: Difference in expected goals created vs. conceded.
  • Team Tiers: Categorical ranking of team strength (1-4).
  • Home Advantage: Encoded as a feature in the training set.

About

End-to-End Machine Learning application built with Django and Scikit-Learn. Predicts Premier League match outcomes using Rolling Averages, xG analysis, and Team Tier classification.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages