Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Scales of Justice

Court Judgments Prediction using Machine Learning

Supreme Court of Nigeria (SCN) appeal-case outcome prediction with an interpretable machine learning workflow.

Version 1.0.0 MIT License Machine learning project

Python Pandas NumPy Scikit-learn Seaborn Jupyter Notebook

Project intro Dataset Install methods

Table of Contents

πŸš€ Project intro

This repository demonstrates an end-to-end machine learning workflow for predicting the outcome of Supreme Court of Nigeria appeal cases. The project combines dataset profiling, exploratory analysis, feature preprocessing, and classifier comparison in a single reproducible notebook-based pipeline.

The main goals are to:

  • profile the legal case dataset and inspect its structure
  • prepare categorical and numerical features for model training
  • compare multiple classification models for case outcome prediction
  • generate visual artifacts such as confusion matrices and correlation plots

πŸ“ Project structure

Court-Judgments-Prediction-using-Machine-Learning/
β”œβ”€β”€ CSE 445.ipynb
β”œβ”€β”€ scn_appeal_cases_data.csv
β”œβ”€β”€ datasetprofiling.html
β”œβ”€β”€ Dataset description.pdf
β”œβ”€β”€ IMAGES/
β”œβ”€β”€ scripts/
β”‚   └── download_judgement_flaticon.ps1
β”œβ”€β”€ LICENSE
└── README.md

πŸ“Š Dataset

Dataset characteristics

Features and target variable

The dataset contains both categorical and numerical attributes such as:

  • appeal district and trial district
  • offence type and sentence category
  • counts of complainants, appellants, and witnesses
  • the target label: scn_decision

These fields make the task suitable for supervised classification with interpretable preprocessing and evaluation.

πŸ§ͺ Methodology

The notebook is organized into four clear stages that support repeatable model development and interpretation.

1. Data ingestion and profiling

  • Load scn_appeal_cases_data.csv into pandas
  • Validate data quality and missing values
  • Generate an automated profile report with pandas-profiling
  • Inspect class balance and feature distributions

2. Exploratory analysis and feature engineering

  • Visualize distributions for categorical and numerical attributes
  • Plot correlation matrices and pairwise relationships
  • Identify informative legal attributes and reduce noise
  • Encode categorical features and scale numeric values when needed

3. Training workflow

  • Split the dataset into training and testing subsets
  • Train a set of classifiers on the processed feature set
  • Compare baseline, linear, tree-based, and neural models
  • Models evaluated include:
    • DummyClassifier
    • LogisticRegression
    • DecisionTreeClassifier
    • RandomForestClassifier
    • SVC
    • GaussianNB
    • MLPClassifier
    • AdaBoostClassifier
    • BaggingClassifier
    • VotingClassifier

4. Evaluation and visualization

  • Compute classification metrics: accuracy, precision, recall, F1 score
  • Generate confusion matrices for each classifier
  • Visualize model performance with graphs and heatmaps
  • Compare model behavior across the same test split

πŸ”„ Project flow

flowchart TD
    A[Load SCN appeal-case dataset] --> B[Profile and inspect data]
    B --> C[Engineer features and transform data]
    C --> D[Train classifiers on training data]
    D --> E[Evaluate results and visualize graphs]
Loading

🧰 Tools

The project is implemented using a Python-based data science stack:

  • Python 3.x for data processing and modeling
  • Jupyter Notebook for interactive experimentation
  • pandas and NumPy for data handling
  • matplotlib and seaborn for visualization
  • scikit-learn for preprocessing, modeling, and evaluation
  • pandas-profiling for automated dataset profiling
  • VS Code as the development environment

βš™οΈ Install methods

Option 1: Python environment with pip

git clone https://github.com/shakil-sheikh/Court-Judgments-Prediction-using-Machine-Learning.git
cd Court-Judgments-Prediction-using-Machine-Learning
python -m venv .venv

# Windows
.venv\Scripts\activate

# macOS / Linux
source .venv/bin/activate

pip install --upgrade pip
pip install pandas numpy matplotlib seaborn scikit-learn pandas-profiling jupyter

Option 2: Conda environment

conda create -n court-judgment-prediction python=3.10 -y
conda activate court-judgment-prediction
pip install --upgrade pip
pip install pandas numpy matplotlib seaborn scikit-learn pandas-profiling jupyter

Run the notebook

jupyter notebook "CSE 445.ipynb"

πŸ“ˆ Results

The repository includes a rich set of model evaluation outputs and visual artifacts in the IMAGES folder. These include:

  • confusion matrices for multiple classifiers
  • feature correlation heatmaps
  • count plots for case-related attributes
  • distribution and relationship plots for the legal features

Model comparison summary

Model Typical metrics Analysis
Logistic Regression Balanced accuracy, precision, recall, F1 Provides a stable baseline with interpretable coefficients for legal feature impact.
Decision Tree Precision, recall, support Captures non-linear relationships and highlights the most discriminative case attributes.
Random Forest Accuracy, F1 score, ROC-AUC Offers the best tradeoff between generalization and robustness across dataset splits.
SVM Precision, recall, F1 Useful for higher-dimensional feature spaces and supports margin-based decisions.
MLP Classifier Accuracy, training loss, validation score Demonstrates the potential of a simple neural classifier for more complex feature interactions.

Key findings

  • The notebook evaluates several classifiers rather than relying on a single model.
  • Ensemble methods such as Random Forest generally show stronger overall performance and stable behavior.
  • Interpretable models like Logistic Regression and Decision Tree make it easier to explain predictions in the legal context.
  • Graphs and heatmaps provide visual evidence of feature importance, class separation, and model mistakes.
  • Confusion matrix graphs are used to compare false positives and false negatives across classifiers.

Graphs and visual analysis

  • Confusion matrix heatmaps: show where models confuse appeal outcomes
  • Feature correlation graphs: reveal strong and weak relationships among legal attributes
  • Class distribution plots: compare counts of outcome labels and reveal imbalance
  • Model comparison figures: aggregate performance metrics across classifiers for easy visual ranking

In summary, the project provides a reproducible comparison of multiple machine learning models on the SCN appeal-case dataset and supports selecting the right classifier based on accuracy, interpretability, and robustness.

πŸ“„ License

This project is licensed under the MIT License. See the LICENSE file for details.

About

Judgments Prediction of Supreme Court of Nigeria (SCN)

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages