An open API service indexing awesome lists of open source software.

https://github.com/theoddysey/epl-predictor

EPL โšฝ Prediction App using Streamlit ๐Ÿ”ซ
https://github.com/theoddysey/epl-predictor

epl python random-forest-classifier streamlit

Last synced: 11 days ago
JSON representation

EPL โšฝ Prediction App using Streamlit ๐Ÿ”ซ

Awesome Lists containing this project

README

          

# โšฝ EPL Expected Goals Projector

### Predict Premier League match scores using Machine Learning & Poisson Statistics

![Python](https://img.shields.io/badge/Python-3.x-3776AB?style=for-the-badge&logo=python&logoColor=white)
![Streamlit](https://img.shields.io/badge/Streamlit-FF4B4B?style=for-the-badge&logo=streamlit&logoColor=white)
![Scikit-Learn](https://img.shields.io/badge/Scikit--Learn-F7931E?style=for-the-badge&logo=scikitlearn&logoColor=white)
![XGBoost](https://img.shields.io/badge/XGBoost-189AB4?style=for-the-badge&logo=xgboost&logoColor=white)
![Pandas](https://img.shields.io/badge/Pandas-150458?style=for-the-badge&logo=pandas&logoColor=white)
![License](https://img.shields.io/badge/License-MIT-green?style=for-the-badge)
![Stars](https://img.shields.io/github/stars/TheODDYSEY/EPL-Predictor?style=for-the-badge&color=yellow)
![Forks](https://img.shields.io/github/forks/TheODDYSEY/EPL-Predictor?style=for-the-badge&color=orange)

**[๐Ÿš€ Live Demo โ†’](https://theoddysey-epl-predictor-app-mabpex.streamlit.app/)**

---

## ๐Ÿ“ธ Preview

![App Preview](https://github.com/TheODDYSEY/EPL-Predictor/raw/master/img/app.png)

---

## ๐Ÿ“– About

**EPL Expected Goals Projector** is a Streamlit web app that predicts English Premier League match outcomes using historical match data and four machine learning approaches. Select a season, pick two teams, and get projected scorelines, win probabilities, and RMSE metrics โ€” all in real time.

---

## โœจ Features

- โšฝ **Score projection** โ€” predicted home and away goals for any EPL fixture
- ๐Ÿ“Š **Win probability** โ€” home win / draw / away win percentages (Poisson model)
- ๐Ÿค– **4 prediction models** โ€” Poisson, Random Forest, XGBoost, and Ensemble
- ๐Ÿ“… **Multi-season support** โ€” select and compare across different EPL seasons
- ๐Ÿ“ˆ **RMSE display** โ€” model accuracy metric shown per prediction
- โœ… **Actual score comparison** โ€” shows real result if the match has already happened
- ๐Ÿง  **Feature selection** โ€” automatically identifies most correlated stats per model

---

## ๐Ÿค– Models

| Model | Type | Description |
|---|---|---|
| **Poisson Distribution** | Statistical | Models goals as independent Poisson processes; outputs win probabilities |
| **Random Forest** | ML Regressor | Ensemble of decision trees trained on cumulative team stats |
| **XGBoost** | ML Regressor | Gradient-boosted trees; handles non-linear feature interactions |
| **Ensemble** | Combined | Averages RF and XGBoost predictions for reduced variance |

---

## โš™๏ธ How It Works

### 1 โ€” Data Preparation
Historical EPL match CSV files are loaded from `engg_data/`. Each file is cleaned and transformed to produce per-team cumulative statistics: wins, draws, losses, points, goals scored, goals conceded, and league position up to each matchday.

### 2 โ€” Feature Selection
For each prediction target (home goals, away goals), the pipeline computes Pearson correlations against all available features and selects the most correlated subset to feed into the model.

### 3 โ€” Model Training
Separate regression models are trained for home goals and away goals. The Ensemble model averages the outputs of Random Forest and XGBoost. Poisson parameters (ฮป_home, ฮป_away) are derived from historical attack and defence strength ratios.

### 4 โ€” Prediction
When a fixture is selected, the system retrieves each team's latest cumulative stats up to that matchday, feeds them into the chosen model, and returns projected scorelines.

### 5 โ€” Visualization
The Streamlit UI displays the projected score, win probabilities (Poisson), RMSE, and โ€” if the match has occurred โ€” the actual result for comparison.

---

## ๐Ÿš€ Getting Started

### Prerequisites

- Python 3.x
- pip

### Installation

```bash
# 1. Clone the repository
git clone https://github.com/TheODDYSEY/EPL-Predictor.git
cd EPL-Predictor

# 2. Install dependencies
pip install -r requirements.txt

# 3. Run the app
streamlit run app.py
```

> Open your browser at `http://localhost:8501`

---

## ๐Ÿ–ฅ๏ธ Usage

1. Select an **EPL season** from the dropdown
2. Choose a **prediction model** โ€” Poisson, RandomForest, XGBoost, or Ensemble
3. Pick the **Home team** and **Away team**
4. Click **Run**
5. View projected score, win probabilities, actual result, and RMSE

---

## ๐Ÿ“ Project Structure

```
EPL-Predictor/
โ”œโ”€โ”€ app.py # Streamlit application entry point
โ”œโ”€โ”€ requirements.txt # Python dependencies
โ”œโ”€โ”€ engg_data/ # Engineered CSV files per EPL season
โ”œโ”€โ”€ data/ # Raw historical match data
โ””โ”€โ”€ img/
โ””โ”€โ”€ app.png # App preview screenshot
```

---

## ๐Ÿ› ๏ธ Tech Stack

| Library | Purpose |
|---|---|
| ![Streamlit](https://img.shields.io/badge/Streamlit-FF4B4B?logo=streamlit&logoColor=white) | Web UI framework |
| ![Pandas](https://img.shields.io/badge/Pandas-150458?logo=pandas&logoColor=white) | Data loading, cleaning, feature engineering |
| ![Scikit-Learn](https://img.shields.io/badge/Scikit--Learn-F7931E?logo=scikitlearn&logoColor=white) | Random Forest Regressor, metrics |
| ![XGBoost](https://img.shields.io/badge/XGBoost-189AB4?logo=xgboost&logoColor=white) | Gradient-boosted regression |
| `SciPy` | Poisson distribution and probability calculations |

---

## ๐Ÿค Contributing

Pull requests and issues are welcome. Fork the repo, make your changes, and open a PR.

---

## ๐Ÿ“„ License

Licensed under the [MIT License](LICENSE).

---

## ๐Ÿ™ Acknowledgments

- [Football-Data.org](https://www.football-data.org/) for historical EPL match data
- [Streamlit](https://streamlit.io/) for the web framework
- [Scikit-learn](https://scikit-learn.org/) and [XGBoost](https://xgboost.readthedocs.io/) for ML algorithms

---

## โญ Star History

[![Star History Chart](https://api.star-history.com/svg?repos=TheODDYSEY/EPL-Predictor&type=Date)](https://star-history.com/#TheODDYSEY/EPL-Predictor&Date)

---

Made with โค๏ธ using Python & Streamlit ย ยทย  โšฝ Happy predicting!