Premier League AI Chatbot
An AI-powered chatbot for querying Premier League football data, built as coursework for ISYS30221 Artificial Intelligence at Nottingham Trent University (2025).
The chatbot combines multiple AI techniques — AIML pattern matching, logic-based reasoning, fuzzy logic, CNN image classification, and a live football API — to answer a wide range of questions about the Premier League.
Features
Core Tasks
- AIML Chatbot (Task a) — natural language Q&A about the Premier League using a pattern-matched AIML knowledge base, with Wikipedia fallback for unknown queries
- Logic-based reasoning (Task b) — fact storage and retrieval for teams, managers, and players using CSV-backed knowledge bases; supports "I know that..." and "Check that..." commands
- CNN Image Classification (Task c) — classifies Premier League club logos from images using a trained and hyperparameter-tuned Convolutional Neural Network (Keras/TensorFlow)
Extra Tasks
- Live Football API — fetches real-time Premier League standings, top scorers, and upcoming matches from the football-data.org API
- Fuzzy Logic — estimates the likelihood of a team finishing in the top 4 using fuzzy membership functions
- Hyperparameter Optimisation — CNN model tuned using Keras Tuner for improved classification accuracy
Tech Stack
| Component | Technology |
|---|
| Chatbot engine | AIML (aiml library) |
| Machine learning | TensorFlow / Keras |
| Hyperparameter tuning | Keras Tuner |
| Fuzzy logic | Custom implementation |
| Live data | football-data.org API |
| Fallback knowledge | Wikipedia API |
| Language | Python |
Project Structure
Chatbox2/
├── main.py # Entry point — chatbot main loop
├── core/
│ ├── knowledge_base.py # Fallback Q&A knowledge base
│ ├── team_logic.py # Team fact storage and checking
│ ├── manager_logic.py # Manager logic and queries
│ ├── players_logic.py # Player team lookups
│ ├── my_fuzzy_logic.py # Fuzzy top-4 likelihood
│ └── football_data_api.py # Live Premier League API calls
├── models/
│ ├── cnn_train.py # CNN training script
│ ├── cnn_tune.py # Keras Tuner hyperparameter search
│ ├── class_names.py # EPL club label names
│ └── epl_logos_cnn_tuned.h5 # Trained CNN model (not in repo — see below)
├── aiml_files/
│ └── mybot-basic.xml # AIML pattern definitions
└── data/
├── QA_KB.csv # Q&A knowledge base
├── logical-kb-2.csv # Logic facts
├── manager_logic_kb.csv # Manager data
├── players_logic_kb.csv # Player data
├── fuzzy_facts.csv # Fuzzy logic data
└── epl-logos-big/ # EPL logo images for CNN training
Getting Started
Prerequisites
Installation
-
Clone the repository:
git clone https://github.com/mkinteh/YOUR_REPO_NAME.git
cd Chatbox2
-
Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies:
pip install aiml wikipedia tensorflow keras-tuner requests python-dotenv
-
Create a .env file in the root directory:
FOOTBALL_DATA_API_KEY=your_api_key_here
-
Run the chatbot:
python main.py
CNN Model
The trained model file (epl_logos_cnn_tuned.h5) is not included in the repository due to its file size. To regenerate it:
python models/cnn_train.py # Train the base model
python models/cnn_tune.py # Run hyperparameter tuning
Example Commands
> Who manages Arsenal?
> I know that Manchester City is a top club
> Check that Manchester City is a top club
> Show me the Premier League standings
> Show me the top scorers
> How likely is Chelsea to finish in the top 4?
> Identify logo (then provide an image path)
Author
Muhamed Kinteh (N0994178)
BSc Computer Science & Mathematics — Nottingham Trent University, 2025
Module: ISYS30221 Artificial Intelligence