$ show mhaythornthwaite/Football_Prediction_Project
This repository implements an end-to-end predictive modeling pipeline for Premier League football match outcomes (home win, draw, away win). It ingests raw match statistics from the api-football.com REST API, processes JSON data into structured DataFrames, engineers features using rolling averages (5- and 10-game windows) and team-vs-opponent differentials, trains multiple classifiers (Random Forest, SVM, KNN, MLP) with hyperparameter tuning, and serves live predictions via a Flask web application. The dominant character is data research: the primary deliverable is a set of trained models and an analytical pipeline, with the web server being a secondary deployment artifact. The best-performing model is a Random Forest achieving ~50-51% test accuracy, demonstrating that football outcomes are modestly predictable from historical statistics. The codebase includes modular helper modules for feature engineering, data scaling, and evaluation plotting that are reusable for other sports or time-series classification tasks. However, the project suffers from hardcoded absolute paths, outdated dependencies (Python 3.7, sklearn 0.23.1), plain-text API keys in the repository, and a static dataset that will drift over time.
The LLM identified 3 files worth highlighting for reuse:
Contains self-contained functions for computing rolling averages of team and opponent statistics (shots, fouls, possession, etc.) and generating differential features. The functions `average_stats_df`, `mod_df`, `combining_fixture_id`, and `creating_ml_df` are parameterized and could be reused for any sports dataset with a similar temporal structure.
Provides reusable plotting functions for machine learning model evaluation: `pred_proba_plot` (histogram of predicted probabilities), `plot_cross_val_confusion_matrix` (normalized confusion matrix across CV folds), and `plot_learning_curve`. These utilities are decoupled from the specific football domain and can be applied to any multi-class classification project.
An integration script that orchestrates the full data fetching, preprocessing, model loading, and prediction generation for daily updates. It demonstrates a pattern for automating a research pipeline into a scheduled production run, including API calls with rate limiting, data transformations, and model inference.