Skip to content

Repository files navigation

License: MIT Research Project Python Flask Machine Learning Project Status

Comparative Analysis of Supervised Learning Architectures for Multi-Class Medical Classification

This repository contains the implementation of my undergraduate thesis titled “Comparative Analysis of Supervised Learning Architectures for Multi-Class Medical Classification.”

The project investigates the behavior of classical supervised machine learning models on real-world healthcare datasets, focusing on the comparative evaluation of machine learning models, robustness under noisy and imbalanced data conditions, and practical deployment through an integrated web-based system.

The work evaluates multiple machine learning architectures across several clinical datasets, including Heart Disease, Liver Disease, Chronic Kidney Disease, and Breast Cancer, highlighting both predictive performance and practical limitations of real-world healthcare data.


🎓 Academic Context

This repository accompanies my undergraduate thesis project completed as part of the Bachelor of Technology (B.Tech) in Computer Science and Engineering at Cluster University of Srinagar (2023).

The project was evaluated with an A grade by the university and recognized for its comparative experimental analysis and methodological rigor.


🌟 Research Context

This project was developed as part of my undergraduate thesis research to study how different supervised learning architectures behave when applied to real-world healthcare datasets.

The objective was not only to achieve high predictive accuracy but also to examine:

  • model generalization across different datasets
  • behavior of algorithms under noisy and imbalanced data conditions
  • limitations of tabular healthcare datasets in predictive modelling
  • comparative performance of classical machine learning architectures

The study implements and evaluates multiple supervised learning models including Logistic Regression, Support Vector Machines (SVM), Random Forest, XGBoost, k-NN, and Naive Bayes across multiple clinical prediction tasks.

Table of Contents


🌟 Introduction

This project delivers an end-to-end Machine Learning web application designed for predicting multiple common diseases on a single, intuitive platform. It integrates trained Machine Learning models into a user-friendly Flask-based web interface, allowing users to input relevant clinical parameters and receive real-time predictions for Heart Disease, Liver Disease, Chronic Kidney Disease, and Breast Cancer.

Built with a focus on comprehensive model training, robust selection, and an engaging user experience, this system serves as an excellent resource for educational, research, and demonstration purposes in health informatics and machine learning.

⚠️ Important Disclaimer

This tool is intended strictly for educational and research purposes. The predictions generated by this system are based on machine learning models trained on publicly available datasets and must not be used for medical diagnosis, treatment, or decision-making. Always consult with a qualified healthcare professional for any health concerns or before making any medical decisions. This project is not a medical device.

✨ Features

Our Multiple Disease Prediction System offers a robust set of features, combining advanced machine learning capabilities with a polished web interface:

🧠 Machine Learning Capabilities

  • Comprehensive Model Comparison: Evaluates various ML algorithms (e.g., Logistic Regression, SVM, KNN, Random Forest, XGBoost) to identify optimal performers for each disease.
  • In-depth Error Analysis: Utilizes Confusion Matrices, ROC Curves, and AUC scoring for detailed performance evaluation.
  • Bias-Variance Analysis: Compares train vs. test performance to assess and mitigate overfitting/underfitting.
  • Automatic Best Model Selection: Identifies and serializes the most suitable model based on predefined metrics for deployment.
  • Deployment-Ready Models: Exports trained models as .pkl files for efficient, seamless integration into the web application.

🌐 Flask Web Application

  • Interactive Web Interface: A dynamic, Flask-based application providing an intuitive platform for all predictions.
  • Responsive & Modern UI: Features a clean, professional design built with HTML5, CSS3, and JavaScript, ensuring a seamless experience across various devices.
  • Dedicated Prediction Forms: Each supported disease has a specific, clearly structured input form with descriptions for required parameters.
  • Real-time Predictions: Provides immediate prediction results with clear, color-coded output (Green = Low Risk, Red = High Risk).
  • Mobile-Friendly Navigation: Ensures accessibility and ease of use on smartphones and tablets.
  • Loading Animation: Enhances user experience during model prediction processing, indicating active computation.

🎨 UI & UX Highlights

  • Professional Layout: Visually appealing and suitable for demonstrations or educational settings.
  • Clear Structure: Clearly structured forms and centered content cards for improved readability.
  • Informative Sections: Provides descriptive text and relevant icons for each disease.
  • Concise Outcomes: Presents prediction results clearly and concisely.

🧠 Supported Diseases & Best Models

The project currently supports predictions for the following diseases, leveraging carefully selected and optimized Machine Learning models:

Disease Best Model Test Accuracy Notes
Heart Disease Logistic Regression ~88.52% Strong generalization, low overfitting
Liver Disease Logistic Regression ~73.50% Most stable across splits
Chronic Kidney Disease Decision Tree ~100% Dataset is highly separable
Breast Cancer Random Forest ~97.37% Best precision & F1 score

Each selected model is trained on its respective full dataset and saved as a serialized .pkl file. The Flask application efficiently loads these models for real-time predictions.

📊 ML Development Workflow

Each disease prediction model follows a comprehensive Machine Learning development workflow, meticulously documented in individual Jupyter notebooks:

  1. Load Dataset: Ingestion of raw, publicly available datasets.
  2. Handle Missing Values: Implementation of strategies for data imputation or removal.
  3. Clean & Preprocess Features: Essential steps including feature scaling, encoding, and transformation.
  4. Define Multiple Candidate Models: Exploration and configuration of various ML algorithms (e.g., Logistic Regression, SVM, KNN, Random Forest, XGBoost).
  5. Train Models & Compute Metrics: Training on preprocessed data and rigorous calculation of performance metrics:
    • Accuracy
    • Precision
    • Recall
    • F1 Score
  6. Visualize Performance: Generation of insightful visualizations:
    • Confusion Matrices for error analysis.
    • ROC Curves and AUC scores for model discrimination.
    • Comparison of train vs. test metrics to assess overfitting/underfitting tendencies.
  7. Select the Best Model: Identification of the optimal model based on evaluated metrics, stability, and generalization ability.
  8. Save Model: Serialization of the chosen model to a .pkl file for seamless deployment within the web application.

⚠️ Data Challenges & Limitations

This project intentionally worked with publicly available healthcare datasets to reflect real-world constraints rather than idealized experimental conditions.

Several limitations were observed during experimentation:

  • Data scarcity and noise: Some datasets, particularly the Indian Liver Patient Dataset, contained missing values, noisy measurements, and overlapping feature distributions, which limited model separability.
  • Class imbalance: Certain disease classes were underrepresented, affecting recall and stability across train–test splits.
  • Lower liver disease performance: Liver disease prediction achieved approximately 73.5% accuracy, significantly lower than other tasks, largely due to weak feature separability and noise amplification during preprocessing.
  • Lack of longitudinal features: All datasets were tabular and static, without temporal or follow-up information, restricting modeling of disease progression.
  • Limited external validation: Models were evaluated on dataset-specific splits and not tested across multiple populations, which may affect generalizability.

These challenges reinforced the importance of robust preprocessing, careful metric selection beyond accuracy, and the need for explainable and uncertainty-aware models in healthcare applications.

📂 Project Structure

The repository is organized to clearly separate the web application components, machine learning notebooks, and datasets:

multiple-disease-prediction/
│
├── App/                             # Flask application core
│   ├── app.py                       # Main Flask application script
│   ├── heart_best_model.pkl         # Serialized best model for Heart Disease
│   ├── liver_best_model.pkl         # Serialized best model for Liver Disease
│   ├── kidney_best_model.pkl        # Serialized best model for Chronic Kidney Disease
│   ├── cancer_best_model.pkl        # Serialized best model for Breast Cancer
│
├── templates/                       # HTML pages (Jinja2 templates)
│   ├── index.html                   # Home page with navigation
│   ├── heart.html                   # Heart Disease prediction form
│   ├── liver.html                   # Liver Disease prediction form
│   ├── kidney.html                  # Chronic Kidney Disease prediction form
│   ├── cancer.html                  # Breast Cancer prediction form
│   ├── predict.html                 # Generic prediction result display template
│   ├── result_history.html          # (Placeholder for future feature: DB logging currently disabled)
│
├── static/                          # Static assets (CSS, JS, images)
│   ├── style.css                    # Modern CSS styles for the application
│   ├── main.js                      # JavaScript for interactive elements (menu, loading animations)
│   └── images/                      # UI icons and visual assets
│
├── Notebooks/                       # Jupyter notebooks for ML model development & analysis
│   ├── Heart.ipynb                  # Heart Disease ML workflow
│   ├── Liver.ipynb                  # Liver Disease ML workflow
│   ├── Kidney.ipynb                 # Chronic Kidney Disease ML workflow
│   └── Cancer.ipynb                 # Breast Cancer ML workflow
│
├── Dataset/                         # Raw datasets used for training the models
│   ├── heart.csv
│   ├── kidney_disease.csv
│   ├── indian_liver_patient.csv
│   └── cancer.csv
│
├── requirements.txt                 # Python dependencies for the project
├── Procfile                         # Configuration for deployment (e.g., Gunicorn on Heroku)
├── README.md                        # Project documentation (this file)
├── LICENSE                          # Project license details
└── venv/                            # Local Python virtual environment (ignored by Git)

📸 Screenshots

A glimpse into the user interface of the Multiple Disease Prediction System:

Screenshot (106).png Home Page with disease selection

Screenshot (107).png Heart Disease prediction form

Screenshot (108).png Prediction Result display

Screenshot (109).png Responsive design on a smaller screen

🛠️ Tech Stack

The project leverages a robust set of technologies for both the Machine Learning backend and the Flask web frontend:

  • Python: The core programming language (version 3.11).
  • Flask: A lightweight Python web framework for building the application.
  • Scikit-learn: For machine learning model development, training, and evaluation.
  • Pandas: For data manipulation and analysis.
  • NumPy: For numerical operations.
  • Matplotlib / Seaborn: For data visualization in notebooks.
  • Jupyter Notebook: For interactive ML development and documentation.
  • HTML5, CSS3, JavaScript: For the responsive and interactive user interface.

🚀 Getting Started

Follow these steps to set up and run the Multiple Disease Prediction System on your local machine.

Prerequisites

  • Python 3.8+ (recommended 3.11)
  • pip (Python package installer)

1️⃣ Clone the Repository

First, clone the project repository to your local machine:

git clone https://github.com/your-username/multiple-disease-prediction.git
cd multiple-disease-prediction

2️⃣ Create and Activate a Virtual Environment

It's highly recommended to use a virtual environment to manage dependencies:

python -m venv venv

On Windows:

.\venv\Scripts\activate

On macOS/Linux:

source venv/bin/activate

3️⃣ Install Dependencies

Once your virtual environment is active, install the required Python packages:

pip install -r requirements.txt

4️⃣ Run the Application

With all dependencies installed, you can now run the Flask application:

python App/app.py

The application will typically be available at http://127.0.0.1:5000/ in your web browser.

💡 Usage

  1. Access the Application: Open your web browser and navigate to http://127.0.0.1:5000/.
  2. Select a Disease: From the home page, choose the disease you wish to predict (Heart, Liver, Kidney, or Cancer).
  3. Input Parameters: You will be directed to a dedicated form for the selected disease. Enter the required clinical parameters into the input fields. Ensure to provide valid numerical inputs as specified.
  4. Get Prediction: Click the "Predict" button. The system will process your inputs using the pre-trained Machine Learning model.
  5. View Results: The prediction result will be displayed, indicating whether the individual is at "Low Risk" (Green) or "High Risk" (Red) for the selected disease, along with a probability score if available.

🤝 Contributing

Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! ⭐ Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📜 License

Distributed under the MIT License. See LICENSE for more information.

🙏 Acknowledgements

📚 Data Sources: The datasets used for training and evaluating the machine learning models are sourced from reputable public repositories:

Kaggle and UCI Machine Learning Repository

💡 Suggestions for Improvement

To further enhance this project, consider the following actionable tips:

  1. Implement User Authentication & Profiles: Add user registration and login functionality to allow users to save their prediction history, manage profiles, and potentially track changes over time.
  2. Add a Database for Predictions: Integrate a database (e.g., SQLite, PostgreSQL) to persistently store user inputs and prediction results. This would enable the "Result History" feature currently marked as a placeholder and facilitate further analysis.
  3. Improve Model Explainability (XAI): Incorporate techniques like SHAP or LIME to provide insights into why a particular prediction was made. This enhances trust and understanding, especially in a health context.
  4. Containerization with Docker: Provide a Dockerfile and docker-compose.yml to enable easy and consistent deployment across different environments, simplifying setup for new contributors or users.
  5. Expand Disease Prediction Scope: Research and integrate models for additional common diseases (e.g., Diabetes, Parkinson's Disease) to broaden the utility of the platform.

About

Comparative study of supervised machine learning architectures for multi-class medical classification using real-world clinical datasets.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages