A machine learning project that predicts the winner of Pakistan Super League (PSL) matches using historical data. It includes data preprocessing, exploratory analysis, and model training using Random Forest , achieving high accuracy in predicting match outcomes.
This project aims to predict the winner of Pakistan Super League (PSL) cricket matches using historical match data.
The model analyzes factors such as the playing teams, toss results, venues, and other match attributes to estimate the most likely winner.
This end-to-end solution includes:
- Data preprocessing and exploratory data analysis (EDA)
- Feature encoding and transformation
- Model training and evaluation using top-performing ML algorithm
- Visualization of performance metrics
- Model persistence for deployment and future use
The main goal of this project is to: Build a supervised machine learning model that can predict the winner of PSL matches based on available historical data.
Specifically, the project focuses on:
- Understanding the relationship between match features (teams, toss, venue, etc.) and outcomes.
- Training multiple ML model
- Evaluating model performance using metrics like accuracy, classification report, and confusion matrix.
- Saving trained pipelines for real-time or batch predictions.
✅ Automated dataset discovery – Automatically locates and loads the PSL dataset from Kaggle environment.
✅ Robust preprocessing – Handles missing data, encodes categorical features, and scales numeric attributes.
✅ model trained – Random Forest Classifier
✅ Comprehensive Evaluation – Accuracy, classification report, and confusion matrix visualization.
✅ Label Encoding – Consistent numeric encoding of team names for compatibility with XGBoost.
✅ Prediction on Unseen Data – Make predictions for new/unseen match records.
✅ Model Persistence – Pipelines and encoders saved using joblib for reuse or deployment.
| Category | Tools/Packages |
|---|---|
| Language | Python 3.x |
| Libraries | pandas, numpy, matplotlib, scikit-learn, joblib |
| Environment | Kaggle / Jupyter Notebook |
| Visualization | matplotlib, ConfusionMatrixDisplay |
| Model Saving | joblib |
Dataset Source: Pakistan Super League Dataset on Kaggle
Dataset Description:
The dataset includes detailed match-level information from PSL seasons, such as:
team1,team2— competing teamsvenue,city— match location detailstoss_winner,toss_decision— toss resultsresult,winner— final match outcome
Target Variable:
winner — The team that won the match.
- Import libraries and setup environment
- Auto-detect and load dataset from
/kaggle/input - EDA – Inspect missing values, value distributions, and target class balance
- Feature Engineering – Encode categorical variables and scale numerical features
- Train-Test Split (80-20)
- Train two models – RandomForest
- Evaluate models – Accuracy, classification report, and confusion matrix
- Predict on unseen data
- Save trained models and label encoder for future use
- RandomForestClassifier
Both models were trained on preprocessed features using a unified scikit-learn Pipeline.
Example Evaluation Output:
Muqadas Ejaz
BS Computer Science (AI Specialization)
AI/ML Engineer
Data Science & Gen AI Enthusiast
📫 Connect with me on LinkedIn
🌐 GitHub: github.com/muqadasejaz
📬 Kaggle: Kaggle Profile
This project is open-source and available under the MIT License.

