Skip to content

Latest commit

ย 

History

25 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿงฌ CancerXAI โ€” Multi-Cancer Subtype Classification with Explainable AI

CancerXAI is a full-stack machine learning web application that predicts cancer subtypes from high-dimensional gene expression data and provides interpretable predictions using SHAP (SHapley Additive exPlanations).

The project combines machine learning, dimensionality reduction, explainable AI and full-stack development through a Django REST API backend and React frontend.

๐ŸŒ Live Demo: cancerxai.vercel.app


๐Ÿ–ฅ๏ธ Application Preview

Home Page

CancerXAI Home Page

Prediction Results

CancerXAI Prediction Results


๐Ÿ“Œ Project Overview

Gene expression datasets can contain tens of thousands of biological features, making cancer subtype classification a challenging machine learning problem.

CancerXAI was developed as my Final Year Computer Science Project at the University of Surrey to investigate how machine learning and explainable AI could be combined within an accessible web application.

The project involved:

  • Processing high-dimensional gene expression data
  • Cleaning and preparing data for machine learning
  • Reducing dimensionality using PCA
  • Training and comparing multiple classification models
  • Evaluating classification performance
  • Applying SHAP for model explainability
  • Developing a REST API for machine learning inference
  • Building an interactive frontend for uploading data and viewing predictions

โœจ Features

  • ๐Ÿ“ค Upload gene expression data in CSV format
  • ๐Ÿงฌ Predict cancer subtypes from gene expression profiles
  • ๐Ÿค– Machine learning-based classification
  • ๐Ÿ“Š Process multiple samples in a single upload
  • ๐Ÿ” SHAP-based model explanations
  • ๐Ÿ“‹ View prediction results through an interactive interface
  • ๐Ÿ“ฅ Download batch prediction results as CSV
  • ๐Ÿ’ป Responsive web interface

๐Ÿง  Machine Learning Pipeline

The machine learning workflow was designed to process high-dimensional gene expression data and produce cancer subtype predictions.

1. Data Preprocessing

The preprocessing pipeline included:

  • Handling missing values
  • Cleaning and preparing gene expression features
  • Standardising numerical features
  • Encoding target labels
  • Preparing datasets for model training and evaluation

2. Dimensionality Reduction

Gene expression datasets contain a very large number of features.

Principal Component Analysis (PCA) was used to reduce the dimensionality of the feature space, helping make model training more computationally manageable while retaining useful information for classification.

3. Model Development

Multiple machine learning approaches were trained and compared:

  • Support Vector Machine (SVM)
  • Random Forest
  • Neural Network

Model performance was evaluated and compared during development to identify an effective approach for cancer subtype classification.

4. Explainable AI

SHAP was incorporated to improve the interpretability of model predictions.

Rather than presenting only a predicted subtype, the application was designed to provide information about which features contributed to the model's predictions.

This adds an explainability layer to the machine learning pipeline and helps make model behaviour easier to investigate.


๐Ÿ“ˆ Results

During development, the classification pipeline improved from an initial baseline accuracy of approximately:

65% โ†’ ~80%

Dimensionality reduction using PCA substantially reduced the original high-dimensional gene expression feature space while supporting downstream classification.

The project received a First-Class project grade (70%+) as part of my BSc (Hons) Computer Science degree at the University of Surrey.


๐Ÿ—๏ธ System Architecture

CancerXAI follows a full-stack architecture:

Gene Expression CSV
        โ”‚
        โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚    React Frontend   โ”‚
โ”‚                     โ”‚
โ”‚  Upload Interface   โ”‚
โ”‚  Results Dashboard  โ”‚
โ”‚  SHAP Visualisation โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚
           โ”‚ HTTP / REST
           โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Django REST API   โ”‚
โ”‚                     โ”‚
โ”‚  Data Processing    โ”‚
โ”‚  Model Inference    โ”‚
โ”‚  Prediction API     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚
           โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Machine Learning    โ”‚
โ”‚                     โ”‚
โ”‚ Preprocessing       โ”‚
โ”‚ PCA                 โ”‚
โ”‚ Classification      โ”‚
โ”‚ SHAP Explainability โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ› ๏ธ Tech Stack

Area Technologies
Programming Python, JavaScript
Data Processing Pandas, NumPy
Machine Learning scikit-learn, PyTorch
Dimensionality Reduction PCA
Explainable AI SHAP
Backend Django, Django REST Framework
Frontend React.js, Material UI, CSS
API REST
Version Control Git, GitHub

๐Ÿ“ Project Structure

CancerXAI/
โ”‚
โ”œโ”€โ”€ cancer_classification_project/
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ backend/
โ”‚   โ”‚   โ”œโ”€โ”€ models/
โ”‚   โ”‚   โ”œโ”€โ”€ api/
โ”‚   โ”‚   โ”œโ”€โ”€ datasets/
โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ frontend/
โ”‚   โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ public/
โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ ...
โ”‚
โ”œโ”€โ”€ docs/
โ”‚   โ””โ”€โ”€ images/
โ”‚       โ”œโ”€โ”€ cancerxai-home.jpeg
โ”‚       โ””โ”€โ”€ cancerxai-results.png
โ”‚
โ”œโ”€โ”€ .gitattributes
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ ...

The exact project structure may evolve as the application is developed and maintained.


๐Ÿ“ค Input Format

CancerXAI accepts gene expression data in CSV format.

Each row represents a sample, while gene identifiers are represented as input features.

Example:

ENSG00000000003,ENSG00000000005,ENSG99999999999
12.4,0.00,7.4
15.9,0.05,6.7

The application processes the uploaded data before passing it through the trained machine learning pipeline.


๐Ÿ“ฅ Example Prediction Output

The backend returns predictions containing information such as the sample, predicted subtype and associated cancer type.

Example:

{
  "predictions": [
    {
      "sample": 1,
      "subtype": "BRCA_LumA",
      "cancer_type": "Breast"
    },
    {
      "sample": 2,
      "subtype": "Papillary",
      "cancer_type": "Kidney"
    }
  ]
}

The frontend presents these predictions through the CancerXAI results interface.


๐Ÿš€ Running the Project Locally

1. Clone the Repository

git clone https://github.com/atriyaaa/CancerXAI.git
cd CancerXAI

If required by the repository:

git lfs install
git lfs pull

2. Backend Setup

Navigate to the backend directory:

cd cancer_classification_project/backend

Create a virtual environment:

python3 -m venv venv

Activate it on macOS/Linux:

source venv/bin/activate

On Windows:

venv\Scripts\activate

Install the required dependencies:

pip install -r requirements.txt

Start the Django development server:

python manage.py runserver

3. Frontend Setup

Open another terminal and navigate to the frontend directory:

cd cancer_classification_project/frontend

Install dependencies:

npm install

Start the React development server:

npm start

The frontend will normally be available at:

http://localhost:3000

The Django backend will normally run at:

http://127.0.0.1:8000

๐Ÿ” Explainability

One of the main goals of CancerXAI is to go beyond producing a classification result.

Machine learning models can be difficult to interpret, particularly when working with high-dimensional biological data.

CancerXAI therefore incorporates SHAP to provide insight into the contribution of input features to model predictions.

This allows the application to combine:

Prediction
    +
Feature Importance
    +
Model Interpretation

rather than presenting the model purely as a black box.


๐ŸŽฏ What I Learned

Developing CancerXAI provided practical experience across the full lifecycle of a machine learning application, including:

  • Working with high-dimensional datasets
  • Data cleaning and preprocessing
  • Dimensionality reduction
  • Training and evaluating classification models
  • Applying explainable AI techniques
  • Building REST APIs
  • Connecting machine learning models to a web application
  • Developing a React-based user interface
  • Debugging frontend/backend integration
  • Managing a larger software project with Git and GitHub

The project also strengthened my understanding of the challenges involved in translating a machine learning model into a usable end-to-end application.


๐Ÿ”ฎ Future Improvements

Potential future development includes:

  • More detailed SHAP visualisations for individual samples
  • Additional model evaluation and comparison metrics
  • Support for additional datasets and subtype classifications
  • Improved error handling and data validation
  • Authentication and user accounts
  • Prediction history
  • Improved deployment architecture
  • Containerisation with Docker
  • Automated testing and CI/CD
  • Further frontend accessibility and usability improvements

โš ๏ธ Disclaimer

CancerXAI was developed as an academic Computer Science project.

The predictions generated by the application are intended for educational and research demonstration purposes and should not be used for clinical diagnosis or medical decision-making.


๐ŸŽ“ Academic Context

CancerXAI was developed as my Final Year Project for the BSc (Hons) Computer Science degree at the University of Surrey.

The project demonstrates practical experience across:

Machine Learning โ€ข Data Analytics โ€ข Explainable AI โ€ข REST APIs โ€ข Full-Stack Development โ€ข Software Engineering


๐Ÿ‘ฉโ€๐Ÿ’ป Author

Atriya Sivakumar

BSc (Hons) Computer Science
University of Surrey

๐ŸŒ Portfolio
๐Ÿ’ผ LinkedIn


โญ If you found this project interesting, feel free to explore the repository and application.

About

Explainable AI web application for cancer subtype classification using gene expression data, machine learning and SHAP.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages